adding in rest macros
This commit is contained in:
parent
a58c813dda
commit
83a9bdc87d
@ -103,3 +103,14 @@ def first_macro(tree):
|
||||
return HyExpression([HySymbol('get'),
|
||||
ret,
|
||||
HyInteger(0)])
|
||||
|
||||
|
||||
@macro("cdr")
|
||||
@macro("rest")
|
||||
def rest_macro(tree):
|
||||
tree.pop(0) # "first"
|
||||
ret = tree.pop(0) # the list
|
||||
# assert tree is empty
|
||||
return HyExpression([HySymbol('slice'),
|
||||
ret,
|
||||
HyInteger(1)])
|
||||
|
@ -183,3 +183,8 @@
|
||||
(assert (= (slice [1 2 3 4 5] 1) [2 3 4 5]))
|
||||
(assert (= (slice [1 2 3 4 5] 1 3) [2 3]))
|
||||
(assert (= (slice [1 2 3 4 5]) [1 2 3 4 5])))
|
||||
|
||||
|
||||
(defn test-rest []
|
||||
"NATIVE: test rest"
|
||||
(assert (= (rest [1 2 3 4 5]) [2 3 4 5])))
|
||||
|
Loading…
Reference in New Issue
Block a user