Skip to content

Commit

Permalink
hy.contrib.walk: Add support for walking cons cells
Browse files Browse the repository at this point in the history
Signed-off-by: Gergely Nagy <[email protected]>
  • Loading branch information
algernon committed Feb 1, 2014
1 parent fa24042 commit e8dfe5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hy/contrib/walk.hy
Original file line number Diff line number Diff line change
Expand Up @@ -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)]))
Expand Down
1 change: 1 addition & 0 deletions tests/native_tests/contrib/walk.hy
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit e8dfe5b

Please sign in to comment.