fix eval
This commit is contained in:
parent
f24948d5db
commit
efe548cfa5
2 changed files with 11 additions and 6 deletions
|
@ -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…
Reference in a new issue