Adding in a Threading macro (->)
This commit is contained in:
parent
d68c1149e2
commit
daa6443e7c
@ -45,3 +45,15 @@ def cond_macro(tree):
|
||||
ret = n
|
||||
|
||||
return root
|
||||
|
||||
|
||||
@macro("_>")
|
||||
def threading_macro(tree):
|
||||
tree.pop(0) # ->
|
||||
tree.reverse()
|
||||
ret = tree.pop(0)
|
||||
root = ret
|
||||
for node in tree:
|
||||
ret.insert(1, node)
|
||||
ret = node
|
||||
return root
|
||||
|
@ -131,3 +131,8 @@
|
||||
(def foo "3")
|
||||
(assert (= *foo* FOO))
|
||||
(assert (!= *foo* foo)))
|
||||
|
||||
(defn test-threading []
|
||||
"NATIVE: test threading macro"
|
||||
(assert (= (-> (.upper "a b c d") (.replace "A" "X") (.split))
|
||||
["X" "B" "C" "D"])))
|
||||
|
Loading…
x
Reference in New Issue
Block a user