mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 13:55:55 +03:00
mal: fix vector? sequential? and PRINT for new macro implementation
This commit is contained in:
parent
41a6f77a9b
commit
cb9b0654fe
12
mal/core.mal
12
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]
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user