add as-> macro
This commit is contained in:
parent
d91dbd19f8
commit
7e13bb4e5f
@ -30,6 +30,15 @@
|
|||||||
[hy.models.symbol [HySymbol]]
|
[hy.models.symbol [HySymbol]]
|
||||||
[hy._compat [PY33 PY34]])
|
[hy._compat [PY33 PY34]])
|
||||||
|
|
||||||
|
(defmacro as-> [head name &rest rest]
|
||||||
|
"Becomes ordered assignments to the provided name. The previous result
|
||||||
|
is thus available in each form. Returns the final result, and leaves the name
|
||||||
|
bound to it in the local scope. This behaves like the threading macros, but
|
||||||
|
requires you to specify the threading point per form via the name."
|
||||||
|
`(do (setv
|
||||||
|
~name ~head
|
||||||
|
~@(interleave (repeat name) rest))
|
||||||
|
~name))
|
||||||
|
|
||||||
(defmacro with [args &rest body]
|
(defmacro with [args &rest body]
|
||||||
"shorthand for nested with* loops:
|
"shorthand for nested with* loops:
|
||||||
|
Loading…
Reference in New Issue
Block a user