This commit is contained in:
Yann Esposito (Yogsototh) 2017-04-20 00:05:40 +02:00
parent f24948d5db
commit efe548cfa5
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
2 changed files with 11 additions and 6 deletions

View file

@ -1,11 +1,13 @@
(do
;; This is lish core
;; increment
def inc (fn [x] (+ x 1))
(def inc (fn [x] (+ x 1)))
;; map
def map (fn [f lst]
(def map (fn [f lst]
(if (empty? lst)
[]
(cons (f (first lst))
(map f (rest lst)))))
(map f (rest lst))))))
)

View file

@ -182,8 +182,11 @@ def _ exprs =
<> "instead got: " <> toS (show exprs)
doCommand :: Command
doCommand reduceLambda exprs = do
foldl' (\_ x -> reduceLambda x) (return Void) exprs
doCommand reduceLambda (expr:nexpr:exprs) = do
_ <- reduceLambda expr
doCommand reduceLambda (nexpr:exprs)
doCommand reduceLambda (expr:[]) = reduceLambda expr
doCommand _ _ = return Void
lishIf :: Command
lishIf reduceLambda (sexp:sexp1:sexp2:[]) = do
@ -282,7 +285,7 @@ unstrictCommands = [ ("if", InternalCommand "if" lishIf)
, ("do", InternalCommand "do" doCommand)
, ("=", InternalCommand "=" equal)
, ("export", InternalCommand "export" export)
-- , ("eval", InternalCommand "eval" eval)
, ("eval", InternalCommand "eval" evalStr)
-- list ops
, ("empty?",InternalCommand "empty?" emptyCmd)
, ("first",InternalCommand "first" firstCmd)