hy.contrib.walk: Add support for walking cons cells

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
Gergely Nagy 2014-02-01 18:36:57 +01:00
parent fa24042cb0
commit e8dfe5bfb2
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F
2 changed files with 4 additions and 0 deletions

View File

@ -32,6 +32,9 @@
(outer (HyExpression (map inner form)))]
[(instance? HyDict form)
(HyDict (outer (HyExpression (map inner form))))]
[(cons? form)
(outer (cons (inner (first form))
(inner (rest form))))]
[(instance? list form)
((type form) (outer (HyExpression (map inner form))))]
[true (outer form)]))

View File

@ -3,6 +3,7 @@
(def walk-form '(print {"foo" "bar"
"array" [1 2 3 [4]]
"something" (+ 1 2 3 4)
"cons!" (cons 1 2)
"quoted?" '(foo)}))
(defn collector [acc x]