diff --git a/mal/core.mal b/mal/core.mal index 09241c61..87649951 100644 --- a/mal/core.mal +++ b/mal/core.mal @@ -14,6 +14,14 @@ true false))) +(def! false_on_macro (fn* [f] + (fn* [x] + (if (_macro_unwrap x) + false + (f x))))) +(def! _sequential? (false_on_macro sequential?)) +(def! _vector? (false_on_macro vector?)) + (def! core_ns [['= =] ['throw throw] @@ -49,7 +57,7 @@ ['list list] ['list? list?] ['vector vector] - ['vector? vector?] + ['vector? _vector?] ['hash-map hash-map] ['map? map?] ['assoc assoc] @@ -59,7 +67,7 @@ ['keys keys] ['vals vals] - ['sequential? sequential?] + ['sequential? _sequential?] ['cons cons] ['concat concat] ['nth nth] diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal index 8b2e6525..4d9c5092 100644 --- a/mal/step8_macros.mal +++ b/mal/step8_macros.mal @@ -44,7 +44,7 @@ (list? ast) (map (fn* [exp] (EVAL exp env)) ast) - (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) + (_vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) (map? ast) (apply hash-map (apply concat @@ -109,7 +109,8 @@ ;; print -(def! PRINT pr-str) +(def! PRINT (fn* [x] + (pr-str (let* [m (_macro_unwrap x)] (if m m x))))) ;; repl (def! repl-env (new-env)) diff --git a/mal/step9_try.mal b/mal/step9_try.mal index 0b93f954..b744f1a0 100644 --- a/mal/step9_try.mal +++ b/mal/step9_try.mal @@ -44,7 +44,7 @@ (list? ast) (map (fn* [exp] (EVAL exp env)) ast) - (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) + (_vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) (map? ast) (apply hash-map (apply concat @@ -118,7 +118,8 @@ ;; print -(def! PRINT pr-str) +(def! PRINT (fn* [x] + (pr-str (let* [m (_macro_unwrap x)] (if m m x))))) ;; repl (def! repl-env (new-env)) diff --git a/mal/stepA_mal.mal b/mal/stepA_mal.mal index 189ae393..ad75a70f 100644 --- a/mal/stepA_mal.mal +++ b/mal/stepA_mal.mal @@ -44,7 +44,7 @@ (list? ast) (map (fn* [exp] (EVAL exp env)) ast) - (vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) + (_vector? ast) (apply vector (map (fn* [exp] (EVAL exp env)) ast)) (map? ast) (apply hash-map (apply concat @@ -118,7 +118,8 @@ ;; print -(def! PRINT pr-str) +(def! PRINT (fn* [x] + (pr-str (let* [m (_macro_unwrap x)] (if m m x))))) ;; repl (def! repl-env (new-env))