require
parent f24948d5db
commit efe548cfa5
Signed by: yogsototh
GPG Key ID: 7B19A4C650D59646

@ -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))))))
)

@ -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)

Loading…
Cancel
Save