From efe548cfa5b67c6ff97d859f2759073b3a126328 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Thu, 20 Apr 2017 00:05:40 +0200 Subject: [PATCH] fix eval --- lish/core.lsh | 8 +++++--- src/Lish/InternalCommands.hs | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lish/core.lsh b/lish/core.lsh index 982a50d..bf29710 100644 --- a/lish/core.lsh +++ b/lish/core.lsh @@ -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)))))) +) \ No newline at end of file diff --git a/src/Lish/InternalCommands.hs b/src/Lish/InternalCommands.hs index 4d89273..bb5b357 100644 --- a/src/Lish/InternalCommands.hs +++ b/src/Lish/InternalCommands.hs @@ -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)