mirror of
https://github.com/kanaka/mal.git
synced 2024-07-14 17:10:30 +03:00
load-file: accept empty file or final comment, return nil
Let `load-file` append a new line in case last line contains a comment. Also append `nil` so that the return value is predictible. Remove the existing explicit `nil` from existing sources. Adapt documentation and tests.
This commit is contained in:
parent
402fb331d6
commit
e6d41de4d5
@ -266,7 +266,7 @@ procedure Step6_File is
|
||||
Startup : constant String
|
||||
:= "(def! not (fn* (a) (if a false true)))"
|
||||
& "(def! load-file (fn* (f)"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))";
|
||||
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))";
|
||||
Repl : constant Envs.Ptr := Envs.New_Env;
|
||||
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
|
||||
begin
|
||||
|
@ -346,7 +346,7 @@ procedure Step7_Quote is
|
||||
Startup : constant String
|
||||
:= "(def! not (fn* (a) (if a false true)))"
|
||||
& "(def! load-file (fn* (f)"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))";
|
||||
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))";
|
||||
Repl : constant Envs.Ptr := Envs.New_Env;
|
||||
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
|
||||
begin
|
||||
|
@ -395,7 +395,7 @@ procedure Step8_Macros is
|
||||
Startup : constant String
|
||||
:= "(def! not (fn* (a) (if a false true)))"
|
||||
& "(def! load-file (fn* (f)"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
|
||||
& "(defmacro! cond (fn* (& xs)"
|
||||
& " (if (> (count xs) 0)"
|
||||
& " (list 'if (first xs)"
|
||||
|
@ -425,7 +425,7 @@ procedure Step9_Try is
|
||||
Startup : constant String
|
||||
:= "(def! not (fn* (a) (if a false true)))"
|
||||
& "(def! load-file (fn* (f)"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
|
||||
& "(defmacro! cond (fn* (& xs)"
|
||||
& " (if (> (count xs) 0)"
|
||||
& " (list 'if (first xs)"
|
||||
|
@ -431,7 +431,7 @@ procedure StepA_Mal is
|
||||
Startup : constant String
|
||||
:= "(def! not (fn* (a) (if a false true)))"
|
||||
& "(def! load-file (fn* (f)"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) "")"")))))"
|
||||
& " (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))"
|
||||
& "(defmacro! cond (fn* (& xs)"
|
||||
& " (if (> (count xs) 0)"
|
||||
& " (list 'if (first xs)"
|
||||
|
@ -358,7 +358,7 @@ begin
|
||||
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
|
||||
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
||||
|
@ -449,7 +449,7 @@ begin
|
||||
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
|
||||
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
||||
|
@ -525,7 +525,7 @@ begin
|
||||
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
|
||||
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
|
||||
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
@ -578,7 +578,7 @@ begin
|
||||
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
|
||||
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
|
||||
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
@ -578,7 +578,7 @@ begin
|
||||
Envs.Set (Repl_Env, "eval", New_Func_Mal_Type ("eval", Do_Eval'Unrestricted_Access));
|
||||
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) ""\nnil)"")))))");
|
||||
RE ("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ""odd number of forms to cond"")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
@ -325,7 +325,7 @@ function main(str, ret, i, idx)
|
||||
env_set(repl_env, "'eval", "&eval")
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
|
||||
idx = types_allocate()
|
||||
env_set(repl_env, "'*ARGV*", "(" idx)
|
||||
|
@ -415,7 +415,7 @@ function main(str, ret, i, idx)
|
||||
env_set(repl_env, "'eval", "&eval")
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
|
||||
idx = types_allocate()
|
||||
env_set(repl_env, "'*ARGV*", "(" idx)
|
||||
|
@ -505,7 +505,7 @@ function main(str, ret, i, idx)
|
||||
env_set(repl_env, "'eval", "&eval")
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
|
@ -567,7 +567,7 @@ function main(str, ret, i, idx)
|
||||
env_set(repl_env, "'eval", "&eval")
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
|
@ -570,7 +570,7 @@ function main(str, ret, i, idx)
|
||||
|
||||
rep("(def! *host-language* \"GNU awk\")")
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
|
@ -161,7 +161,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
if [[ "${1}" ]]; then
|
||||
|
@ -206,7 +206,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
if [[ "${1}" ]]; then
|
||||
|
@ -248,7 +248,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
|
@ -261,7 +261,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
|
@ -270,7 +270,7 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
# core.mal: defined using the language itself
|
||||
REP "(def! *host-language* \"bash\")"
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
REP "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
|
@ -372,7 +372,7 @@ MAIN:
|
||||
A$="(def! not (fn* (a) (if a false true)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! load-file (fn* (f) (eval (read-file f))))"
|
||||
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
REM load the args file
|
||||
|
@ -462,7 +462,7 @@ MAIN:
|
||||
A$="(def! not (fn* (a) (if a false true)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! load-file (fn* (f) (eval (read-file f))))"
|
||||
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
REM load the args file
|
||||
|
@ -529,7 +529,7 @@ MAIN:
|
||||
A$="(def! not (fn* (a) (if a false true)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! load-file (fn* (f) (eval (read-file f))))"
|
||||
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"
|
||||
|
@ -562,7 +562,7 @@ MAIN:
|
||||
A$="(def! not (fn* (a) (if a false true)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! load-file (fn* (f) (eval (read-file f))))"
|
||||
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"
|
||||
|
@ -561,7 +561,7 @@ MAIN:
|
||||
A$="(def! not (fn* (a) (if a false true)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! load-file (fn* (f) (eval (read-file f))))"
|
||||
A$="(def! load-file (fn* (f) (do (eval (read-file f)) nil)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs)"
|
||||
|
@ -20,7 +20,7 @@ UNTIL sym$ = ""
|
||||
REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
READ form$
|
||||
|
@ -20,7 +20,7 @@ UNTIL sym$ = ""
|
||||
REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
READ form$
|
||||
|
@ -20,7 +20,7 @@ UNTIL sym$ = ""
|
||||
REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
|
@ -20,7 +20,7 @@ UNTIL sym$ = ""
|
||||
REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
|
@ -20,7 +20,7 @@ UNTIL sym$ = ""
|
||||
REM Initial forms to evaluate
|
||||
RESTORE +0
|
||||
DATA (def! not (fn* (a) (if a false true)))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))
|
||||
DATA (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
DATA (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw "odd number of forms to cond")) (cons 'cond (rest (rest xs)))))))
|
||||
DATA (def! *host-language* "BBC BASIC V")
|
||||
DATA ""
|
||||
|
@ -210,7 +210,7 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
// core.mal: defined using the language itself
|
||||
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -247,7 +247,7 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
// core.mal: defined using the language itself
|
||||
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -289,7 +289,7 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
// core.mal: defined using the language itself
|
||||
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
// core.mal: defined using the language itself
|
||||
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
RE(repl_env, "", "(def! *host-language* \"c\")");
|
||||
RE(repl_env, "", "(def! not (fn* (a) (if a false true)))");
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE(repl_env, "", "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ fun string rep(string input)
|
||||
}
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
fun void main()
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ fun string rep(string input)
|
||||
}
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
fun void main()
|
||||
{
|
||||
|
@ -434,7 +434,7 @@ fun string rep(string input)
|
||||
}
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
fun void main()
|
||||
|
@ -451,7 +451,7 @@ fun string rep(string input)
|
||||
}
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
fun void main()
|
||||
|
@ -453,7 +453,7 @@ fun string rep(string input)
|
||||
}
|
||||
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
fun void main()
|
||||
|
@ -94,7 +94,7 @@
|
||||
|
||||
;; core.mal: defined using the language itself
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
|
||||
;; repl loop
|
||||
(defn repl-loop []
|
||||
|
@ -117,7 +117,7 @@
|
||||
|
||||
;; core.mal: defined using the language itself
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
|
||||
;; repl loop
|
||||
(defn repl-loop []
|
||||
|
@ -151,7 +151,7 @@
|
||||
|
||||
;; core.mal: defined using the language itself
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
;; repl loop
|
||||
|
@ -168,7 +168,7 @@
|
||||
|
||||
;; core.mal: defined using the language itself
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
;; repl loop
|
||||
|
@ -178,7 +178,7 @@
|
||||
#?(:clj (rep "(def! *host-language* \"clojure\")")
|
||||
:cljs (rep "(def! *host-language* \"clojurescript\")"))
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
;; repl loop
|
||||
|
@ -71,7 +71,7 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
repl_env.set types._symbol('*ARGV*'), process.argv[3..]
|
||||
|
@ -87,7 +87,7 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
repl_env.set types._symbol('*ARGV*'), process.argv[3..]
|
||||
|
@ -105,7 +105,7 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
|
@ -114,7 +114,7 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
|
||||
# core.mal: defined using the language itself
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
|
@ -121,7 +121,7 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
# core.mal: defined using the language itself
|
||||
rep("(def! *host-language* \"CoffeeScript\")")
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
|
@ -135,7 +135,7 @@
|
||||
(mal-eval ast *repl-env*))))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
||||
|
@ -171,7 +171,7 @@
|
||||
(mal-eval ast *repl-env*))))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
||||
|
@ -226,7 +226,7 @@
|
||||
(mal-eval ast *repl-env*))))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
@ -249,7 +249,7 @@
|
||||
(mal-eval ast *repl-env*))))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
@ -256,7 +256,7 @@
|
||||
(make-mal-string (lisp-implementation-version)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
(rep "(def! *host-language* \"common-lisp\")")
|
||||
|
||||
|
@ -177,7 +177,7 @@ malValuePtr APPLY(malValuePtr op, malValueIter argsBegin, malValueIter argsEnd)
|
||||
static const char* malFunctionTable[] = {
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
|
||||
};
|
||||
|
||||
static void installFunctions(malEnvPtr env) {
|
||||
|
@ -235,7 +235,7 @@ static malValuePtr quasiquote(malValuePtr obj)
|
||||
static const char* malFunctionTable[] = {
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
|
||||
};
|
||||
|
||||
static void installFunctions(malEnvPtr env) {
|
||||
|
@ -282,7 +282,7 @@ static const char* malFunctionTable[] = {
|
||||
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
|
||||
};
|
||||
|
||||
static void installFunctions(malEnvPtr env) {
|
||||
|
@ -331,7 +331,7 @@ static const char* malFunctionTable[] = {
|
||||
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
|
||||
};
|
||||
|
||||
static void installFunctions(malEnvPtr env) {
|
||||
|
@ -332,7 +332,7 @@ static const char* malFunctionTable[] = {
|
||||
"(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
(eval (read-string (str \"(do \" (slurp filename) \"\nnil)\")))))",
|
||||
"(def! *host-language* \"C++\")",
|
||||
};
|
||||
|
||||
|
@ -157,7 +157,7 @@ REPL_ENV = Mal::Env.new nil
|
||||
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
|
||||
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
|
||||
Mal.rep "(def! not (fn* (a) (if a false true)))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
argv = Mal::List.new
|
||||
REPL_ENV.set("*ARGV*", Mal::Type.new argv)
|
||||
|
||||
|
@ -183,7 +183,7 @@ REPL_ENV = Mal::Env.new nil
|
||||
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
|
||||
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
|
||||
Mal.rep "(def! not (fn* (a) (if a false true)))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
argv = Mal::List.new
|
||||
REPL_ENV.set("*ARGV*", Mal::Type.new argv)
|
||||
|
||||
|
@ -229,7 +229,7 @@ REPL_ENV = Mal::Env.new nil
|
||||
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
|
||||
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
|
||||
Mal.rep "(def! not (fn* (a) (if a false true)))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
|
||||
argv = Mal::List.new
|
||||
|
@ -246,7 +246,7 @@ REPL_ENV = Mal::Env.new nil
|
||||
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
|
||||
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
|
||||
Mal.rep "(def! not (fn* (a) (if a false true)))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
|
||||
argv = Mal::List.new
|
||||
|
@ -252,7 +252,7 @@ REPL_ENV = Mal::Env.new nil
|
||||
Mal::NS.each { |k, v| REPL_ENV.set(k, Mal::Type.new(v)) }
|
||||
REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0], REPL_ENV) })
|
||||
Mal.rep "(def! not (fn* (a) (if a false true)))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
Mal.rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"
|
||||
Mal.rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"
|
||||
Mal.rep("(def! *host-language* \"crystal\")")
|
||||
|
||||
|
@ -154,7 +154,7 @@ namespace Mal {
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
RE("(load-file \"" + args[fileIdx] + "\")");
|
||||
|
@ -186,7 +186,7 @@ namespace Mal {
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
RE("(load-file \"" + args[fileIdx] + "\")");
|
||||
|
@ -225,7 +225,7 @@ namespace Mal {
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
|
@ -246,7 +246,7 @@ namespace Mal {
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
|
@ -247,7 +247,7 @@ namespace Mal {
|
||||
// core.mal: defined using the language itself
|
||||
RE("(def! *host-language* \"c#\")");
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
RE("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
|
@ -178,7 +178,7 @@ void main(string[] args)
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
re("(def! not (fn* (a) (if a false true)))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ void main(string[] args)
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
re("(def! not (fn* (a) (if a false true)))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ void main(string[] args)
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
re("(def! not (fn* (a) (if a false true)))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
|
||||
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
|
@ -290,7 +290,7 @@ void main(string[] args)
|
||||
|
||||
// core.mal: defined using the language itself
|
||||
re("(def! not (fn* (a) (if a false true)))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
|
||||
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
|
@ -292,7 +292,7 @@ void main(string[] args)
|
||||
// core.mal: defined using the language itself
|
||||
re("(def! *host-language* \"" ~ std.compiler.name ~ "\")", repl_env);
|
||||
re("(def! not (fn* (a) (if a false true)))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env);
|
||||
re("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))", repl_env);
|
||||
re("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
|
@ -20,7 +20,7 @@ void setupEnv(List<String> argv) {
|
||||
|
||||
rep('(def! not (fn* (a) (if a false true)))');
|
||||
rep("(def! load-file "
|
||||
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
}
|
||||
|
||||
MalType READ(String x) => reader.read_str(x);
|
||||
|
@ -20,7 +20,7 @@ void setupEnv(List<String> argv) {
|
||||
|
||||
rep('(def! not (fn* (a) (if a false true)))');
|
||||
rep("(def! load-file "
|
||||
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
"(fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
}
|
||||
|
||||
MalType quasiquote(MalType ast) {
|
||||
|
@ -19,7 +19,7 @@ void setupEnv(List<String> argv) {
|
||||
|
||||
rep('(def! not (fn* (a) (if a false true)))');
|
||||
rep("(def! load-file "
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond "
|
||||
" (fn* (& xs) (if (> (count xs) 0) "
|
||||
" (list 'if (first xs) "
|
||||
|
@ -19,7 +19,7 @@ void setupEnv(List<String> argv) {
|
||||
|
||||
rep('(def! not (fn* (a) (if a false true)))');
|
||||
rep("(def! load-file "
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond "
|
||||
" (fn* (& xs) (if (> (count xs) 0) "
|
||||
" (list 'if (first xs) "
|
||||
|
@ -21,7 +21,7 @@ void setupEnv(List<String> argv) {
|
||||
|
||||
rep('(def! not (fn* (a) (if a false true)))');
|
||||
rep("(def! load-file "
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
" (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))");
|
||||
rep("(defmacro! cond "
|
||||
" (fn* (& xs) (if (> (count xs) 0) "
|
||||
" (list 'if (first xs) "
|
||||
|
@ -117,7 +117,7 @@
|
||||
(PRINT (EVAL (READ input) repl-env)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
;; C-d throws an error
|
||||
|
@ -150,7 +150,7 @@
|
||||
(PRINT (EVAL (READ input) repl-env)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
;; C-d throws an error
|
||||
|
@ -180,7 +180,7 @@
|
||||
(PRINT (EVAL (READ input) repl-env)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
|
@ -196,7 +196,7 @@
|
||||
(PRINT (EVAL (READ input) repl-env)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
|
@ -197,7 +197,7 @@
|
||||
(PRINT (EVAL (READ input) repl-env)))
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))")
|
||||
(rep "(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
|
@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step6File do
|
||||
read_eval_print("""
|
||||
(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string (str "(do " (slurp f) ")")))))
|
||||
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
""", env)
|
||||
|
||||
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->
|
||||
|
@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step7Quote do
|
||||
read_eval_print("""
|
||||
(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string (str "(do " (slurp f) ")")))))
|
||||
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
""", env)
|
||||
|
||||
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->
|
||||
|
@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step8Macros do
|
||||
read_eval_print("""
|
||||
(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string (str "(do " (slurp f) ")")))))
|
||||
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
""", env)
|
||||
|
||||
# cond
|
||||
|
@ -27,7 +27,7 @@ defmodule Mix.Tasks.Step9Try do
|
||||
read_eval_print("""
|
||||
(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string (str "(do " (slurp f) ")")))))
|
||||
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
""", env)
|
||||
|
||||
# cond
|
||||
|
@ -35,7 +35,7 @@ defmodule Mix.Tasks.StepAMal do
|
||||
read_eval_print("""
|
||||
(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string (str "(do " (slurp f) ")")))))
|
||||
(eval (read-string (str "(do " (slurp f) "\nnil)")))))
|
||||
""", env)
|
||||
|
||||
# cond
|
||||
|
@ -71,7 +71,7 @@ malInit =
|
||||
, """(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string
|
||||
(str "(do " (slurp f) ")")))))"""
|
||||
(str "(do " (slurp f) "\nnil)")))))"""
|
||||
]
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ malInit =
|
||||
, """(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string
|
||||
(str "(do " (slurp f) ")")))))"""
|
||||
(str "(do " (slurp f) "\nnil)")))))"""
|
||||
]
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ malInit =
|
||||
, """(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string
|
||||
(str "(do " (slurp f) ")")))))"""
|
||||
(str "(do " (slurp f) "\nnil)")))))"""
|
||||
, """(defmacro! cond
|
||||
(fn* (& xs)
|
||||
(if (> (count xs) 0)
|
||||
|
@ -71,7 +71,7 @@ malInit =
|
||||
, """(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string
|
||||
(str "(do " (slurp f) ")")))))"""
|
||||
(str "(do " (slurp f) "\nnil)")))))"""
|
||||
, """(defmacro! cond
|
||||
(fn* (& xs)
|
||||
(if (> (count xs) 0)
|
||||
|
@ -72,7 +72,7 @@ malInit =
|
||||
, """(def! load-file
|
||||
(fn* (f)
|
||||
(eval (read-string
|
||||
(str "(do " (slurp f) ")")))))"""
|
||||
(str "(do " (slurp f) "\nnil)")))))"""
|
||||
, """(defmacro! cond
|
||||
(fn* (& xs)
|
||||
(if (> (count xs) 0)
|
||||
|
@ -19,7 +19,7 @@ init() ->
|
||||
Env = core:ns(),
|
||||
% define the load-file and not functions using mal itself
|
||||
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
|
||||
Env.
|
||||
|
||||
loop(Env) ->
|
||||
|
@ -19,7 +19,7 @@ init() ->
|
||||
Env = core:ns(),
|
||||
% define the load-file and not functions using mal itself
|
||||
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
|
||||
Env.
|
||||
|
||||
loop(Env) ->
|
||||
|
@ -18,7 +18,7 @@ main([]) ->
|
||||
init() ->
|
||||
Env = core:ns(),
|
||||
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
|
||||
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
|
||||
Env.
|
||||
|
||||
|
@ -18,7 +18,7 @@ main([]) ->
|
||||
init() ->
|
||||
Env = core:ns(),
|
||||
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
|
||||
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
|
||||
Env.
|
||||
|
||||
|
@ -20,7 +20,7 @@ init() ->
|
||||
Env = core:ns(),
|
||||
eval(read("(def! *host-language* \"Erlang\")"), Env),
|
||||
eval(read("(def! not (fn* (a) (if a false true)))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"), Env),
|
||||
eval(read("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))"), Env),
|
||||
eval(read("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"), Env),
|
||||
Env.
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user