From e8dfe5bfb20ecd1d19c4913bed2449793ab6204e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sat, 1 Feb 2014 18:36:57 +0100 Subject: [PATCH] hy.contrib.walk: Add support for walking cons cells Signed-off-by: Gergely Nagy --- hy/contrib/walk.hy | 3 +++ tests/native_tests/contrib/walk.hy | 1 + 2 files changed, 4 insertions(+) diff --git a/hy/contrib/walk.hy b/hy/contrib/walk.hy index a69078d..a846ed3 100644 --- a/hy/contrib/walk.hy +++ b/hy/contrib/walk.hy @@ -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)])) diff --git a/tests/native_tests/contrib/walk.hy b/tests/native_tests/contrib/walk.hy index 24feb76..d6ecbf8 100644 --- a/tests/native_tests/contrib/walk.hy +++ b/tests/native_tests/contrib/walk.hy @@ -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]