Added macroexpand-1
This commit is contained in:
parent
033198a90e
commit
defccc6853
@ -227,13 +227,28 @@ macroexpand
|
||||
|
||||
Usage: ``(macroexpand form)``
|
||||
|
||||
Returns the macro expansion of form.
|
||||
Returns the full macro expansion of form.
|
||||
|
||||
.. code-block:: clojure
|
||||
|
||||
=> (macroexpand '(-> (a b) (x y)))
|
||||
(u'x' (u'a' u'b') u'y')
|
||||
|
||||
=> (macroexpand '(-> (a b) (-> (c d) (e f))))
|
||||
(u'e' (u'c' (u'a' u'b') u'd') u'f')
|
||||
|
||||
macroexpand-1
|
||||
-------------
|
||||
|
||||
Usage: ``(macroexpand-1 form)``
|
||||
|
||||
Returns the single step macro expansion of form.
|
||||
|
||||
.. code-block:: clojure
|
||||
|
||||
=> (macroexpand-1 '(-> (a b) (-> (c d) (e f))))
|
||||
(u'_>' (u'a' u'b') (u'c' u'd') (u'e' u'f'))
|
||||
|
||||
neg?
|
||||
----
|
||||
|
||||
|
@ -120,10 +120,15 @@
|
||||
(catch [TypeError] false)))
|
||||
|
||||
(defn macroexpand [form]
|
||||
"Return the macro expansion of form"
|
||||
"Return the full macro expansion of form"
|
||||
(import hy.macros)
|
||||
(hy.macros.macroexpand form --name--))
|
||||
|
||||
(defn macroexpand-1 [form]
|
||||
"Return the single step macro expansion of form"
|
||||
(import hy.macros)
|
||||
(hy.macros.macroexpand-1 form --name--))
|
||||
|
||||
(defn neg? [n]
|
||||
"Return true if n is < 0"
|
||||
(_numeric-check n)
|
||||
@ -219,6 +224,7 @@
|
||||
|
||||
(def *exports* ["cycle" "dec" "distinct" "drop" "drop_while" "empty?" "even?"
|
||||
"filter" "float?" "inc" "instance?" "integer?" "iterable?"
|
||||
"iterate" "iterator?" "macroexpand" "neg?" "none?" "nth"
|
||||
"numeric?" "odd?" "pos?" "remove" "repeat" "repeatedly"
|
||||
"second" "string?" "take" "take_nth" "take_while" "zero?"])
|
||||
"iterate" "iterator?" "macroexpand" "macroexpand_1" "neg?"
|
||||
"none?" "nth" "numeric?" "odd?" "pos?" "remove" "repeat"
|
||||
"repeatedly" "second" "string?" "take" "take_nth" "take_while"
|
||||
"zero?"])
|
||||
|
@ -782,6 +782,14 @@
|
||||
|
||||
|
||||
(defn test-macroexpand []
|
||||
"Test macroexpand on ->"
|
||||
(assert (= (macroexpand '(-> (a b) (x y)))
|
||||
'(x (a b) y))))
|
||||
"Test macroexpand on ->"
|
||||
(assert (= (macroexpand '(-> (a b) (x y)))
|
||||
'(x (a b) y)))
|
||||
(assert (= (macroexpand '(-> (a b) (-> (c d) (e f))))
|
||||
'(e (c (a b) d) f))))
|
||||
|
||||
|
||||
(defn test-macroexpand-1 []
|
||||
"Test macroexpand-1 on ->"
|
||||
(assert (= (macroexpand-1 '(-> (a b) (-> (c d) (e f))))
|
||||
'(-> (a b) (c d) (e f)))))
|
||||
|
Loading…
Reference in New Issue
Block a user