mirror of
https://github.com/kanaka/mal.git
synced 2024-09-11 13:55:55 +03:00
Remove gensym, inc and or from step files.
* Move `gensym` and `inc` from step files to `lib/trivial.mal`. * Move `or` from step files to `lib/test_cascade.mal`. Shorten it because `(first ())` returns `nil` * Update process and tests accordingly (not the figures yet).
This commit is contained in:
parent
903d9203f3
commit
26ced15b31
@ -401,12 +401,7 @@ procedure Step8_Macros is
|
||||
& " (list 'if (first xs)"
|
||||
& " (if (> (count xs) 1) (nth xs 1)"
|
||||
& " (throw ""odd number of forms to cond""))"
|
||||
& " (cons 'cond (rest (rest xs)))))))"
|
||||
& "(defmacro! or (fn* (& xs)"
|
||||
& " (if (empty? xs) nil"
|
||||
& " (if (= 1 (count xs)) (first xs)"
|
||||
& " `(let* (or_FIXME ~(first xs))"
|
||||
& " (if or_FIXME or_FIXME (or ~@(rest xs))))))))";
|
||||
& " (cons 'cond (rest (rest xs)))))))";
|
||||
Repl : constant Envs.Ptr := Envs.New_Env;
|
||||
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
|
||||
begin
|
||||
|
@ -431,12 +431,7 @@ procedure Step9_Try is
|
||||
& " (list 'if (first xs)"
|
||||
& " (if (> (count xs) 1) (nth xs 1)"
|
||||
& " (throw ""odd number of forms to cond""))"
|
||||
& " (cons 'cond (rest (rest xs)))))))"
|
||||
& "(defmacro! or (fn* (& xs)"
|
||||
& " (if (empty? xs) nil"
|
||||
& " (if (= 1 (count xs)) (first xs)"
|
||||
& " `(let* (or_FIXME ~(first xs))"
|
||||
& " (if or_FIXME or_FIXME (or ~@(rest xs))))))))";
|
||||
& " (cons 'cond (rest (rest xs)))))))";
|
||||
Repl : constant Envs.Ptr := Envs.New_Env;
|
||||
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
|
||||
begin
|
||||
|
@ -438,15 +438,6 @@ procedure StepA_Mal is
|
||||
& " (if (> (count xs) 1) (nth xs 1)"
|
||||
& " (throw ""odd number of forms to cond""))"
|
||||
& " (cons 'cond (rest (rest xs)))))))"
|
||||
& "(def! inc (fn* [x] (+ x 1)))"
|
||||
& "(def! gensym (let* [counter (atom 0)]"
|
||||
& " (fn* [] (symbol (str ""G__"" (swap! counter inc))))))"
|
||||
& "(defmacro! or (fn* (& xs)"
|
||||
& " (if (empty? xs) nil"
|
||||
& " (if (= 1 (count xs)) (first xs)"
|
||||
& " (let* (condvar (gensym))"
|
||||
& " `(let* (~condvar ~(first xs))"
|
||||
& " (if ~condvar ~condvar (or ~@(rest xs)))))))))"
|
||||
& "(def! *host-language* ""ada.2"")";
|
||||
Repl : constant Envs.Ptr := Envs.New_Env;
|
||||
function Eval_Builtin (Args : in Types.T_Array) return Types.T is
|
||||
|
@ -527,7 +527,6 @@ begin
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
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)))))))");
|
||||
RE ("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
||||
|
@ -580,7 +580,6 @@ begin
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
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)))))))");
|
||||
RE ("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
||||
|
@ -580,9 +580,6 @@ begin
|
||||
RE ("(def! not (fn* (a) (if a false true)))");
|
||||
RE ("(def! load-file (fn* (f) (eval (read-string (str ""(do "" (slurp f) "")"")))))");
|
||||
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)))))))");
|
||||
RE ("(def! inc (fn* [x] (+ x 1)))");
|
||||
RE ("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str ""G__"" (swap! counter inc))))))");
|
||||
RE ("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
|
||||
-- Command line processing.
|
||||
|
||||
|
@ -507,7 +507,6 @@ function main(str, ret, i, idx)
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
env_set(repl_env, "'*ARGV*", "(" idx)
|
||||
|
@ -569,7 +569,6 @@ function main(str, ret, i, idx)
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
env_set(repl_env, "'*ARGV*", "(" idx)
|
||||
|
@ -572,9 +572,6 @@ function main(str, ret, i, idx)
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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! inc (fn* [x] (+ x 1)))")
|
||||
rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
idx = types_allocate()
|
||||
env_set(repl_env, "'*ARGV*", "(" idx)
|
||||
|
@ -250,7 +250,6 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) \`(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
if [[ "${1}" ]]; then
|
||||
|
@ -263,7 +263,6 @@ ENV_SET "${REPL_ENV}" "${r}" "${argv}";
|
||||
REP "(def! not (fn* (a) (if a false true)))"
|
||||
REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"
|
||||
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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) \`(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
if [[ "${1}" ]]; then
|
||||
|
@ -272,9 +272,6 @@ 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 "(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! inc (fn* [x] (+ x 1)))"
|
||||
REP "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))"
|
||||
REP "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) \`(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))"
|
||||
|
||||
# load/run file from command line (then exit)
|
||||
if [[ "${1}" ]]; then
|
||||
|
@ -537,10 +537,6 @@ MAIN:
|
||||
A$=A$+" forms to cond"+CHR$(34)+")) (cons 'cond (rest (rest xs)))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs)"
|
||||
A$=A$+" `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
REM load the args file
|
||||
A$="(def! -*ARGS*- (load-file "+CHR$(34)+".args.mal"+CHR$(34)+"))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
@ -570,10 +570,6 @@ MAIN:
|
||||
A$=A$+" forms to cond"+CHR$(34)+")) (cons 'cond (rest (rest xs)))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs)"
|
||||
A$=A$+" `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
REM load the args file
|
||||
A$="(def! -*ARGS*- (load-file "+CHR$(34)+".args.mal"+CHR$(34)+"))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
@ -569,18 +569,6 @@ MAIN:
|
||||
A$=A$+" forms to cond"+CHR$(34)+")) (cons 'cond (rest (rest xs)))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! inc (fn* [x] (+ x 1)))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "+CHR$(34)
|
||||
A$=A$+"G__"+CHR$(34)+" (swap! counter inc))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
A$="(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs)"
|
||||
A$=A$+" (let* (c (gensym)) `(let* (~c ~(first xs))"
|
||||
A$=A$+" (if ~c ~c (or ~@(rest xs)))))))))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
||||
REM load the args file
|
||||
A$="(def! -*ARGS*- (load-file "+CHR$(34)+".args.mal"+CHR$(34)+"))"
|
||||
GOSUB RE:AY=R:GOSUB RELEASE
|
||||
|
@ -22,7 +22,6 @@ 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 (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 (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
READ form$
|
||||
|
@ -22,7 +22,6 @@ 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 (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 (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
DATA ""
|
||||
REPEAT
|
||||
READ form$
|
||||
|
@ -22,9 +22,6 @@ 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 (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! inc (fn* [x] (+ x 1)))
|
||||
DATA (def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))
|
||||
DATA (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))
|
||||
DATA (def! *host-language* "BBC BASIC V")
|
||||
DATA ""
|
||||
REPEAT
|
||||
|
@ -291,7 +291,6 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE(repl_env, "", "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -316,7 +316,6 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE(repl_env, "", "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -322,9 +322,6 @@ void init_repl_env(int argc, char *argv[]) {
|
||||
RE(repl_env, "",
|
||||
"(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE(repl_env, "", "(def! inc (fn* [x] (+ x 1)))");
|
||||
RE(repl_env, "", "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
RE(repl_env, "", "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -435,9 +435,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("(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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
fun void main()
|
||||
{
|
||||
|
@ -452,9 +452,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("(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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
fun void main()
|
||||
{
|
||||
|
@ -454,13 +454,8 @@ 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("(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! inc (fn* [x] (+ x 1)))");
|
||||
rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
|
||||
fun void main()
|
||||
{
|
||||
int done;
|
||||
|
@ -153,7 +153,6 @@
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
;; repl loop
|
||||
(defn repl-loop []
|
||||
|
@ -170,7 +170,6 @@
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
;; repl loop
|
||||
(defn repl-loop []
|
||||
|
@ -180,9 +180,6 @@
|
||||
(rep "(def! not (fn* [a] (if a false true)))")
|
||||
(rep "(def! load-file (fn* [f] (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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! inc (fn* [x] (+ x 1)))")
|
||||
(rep "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
(rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
;; repl loop
|
||||
(defn repl-loop []
|
||||
|
@ -107,7 +107,6 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
repl_env.set types._symbol('*ARGV*'), process.argv[3..]
|
||||
|
@ -116,7 +116,6 @@ repl_env.set types._symbol('*ARGV*'), []
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
repl_env.set types._symbol('*ARGV*'), process.argv[3..]
|
||||
|
@ -123,9 +123,6 @@ 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("(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! inc (fn* [x] (+ x 1)))");
|
||||
rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
if process? && process.argv.length > 2
|
||||
repl_env.set types._symbol('*ARGV*'), process.argv[3..]
|
||||
|
@ -228,7 +228,6 @@
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
||||
|
@ -251,7 +251,6 @@
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
||||
|
@ -259,9 +259,6 @@
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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\")")
|
||||
(rep "(def! inc (fn* [x] (+ x 1)))")
|
||||
(rep "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
(rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
(defvar *use-readline-p* nil)
|
||||
|
||||
|
@ -280,7 +280,6 @@ static malValuePtr macroExpand(malValuePtr obj, malEnvPtr env)
|
||||
|
||||
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)))))))",
|
||||
"(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
|
@ -329,7 +329,6 @@ static malValuePtr macroExpand(malValuePtr obj, malEnvPtr env)
|
||||
|
||||
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)))))))",
|
||||
"(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
|
@ -330,12 +330,9 @@ static malValuePtr macroExpand(malValuePtr obj, malEnvPtr env)
|
||||
|
||||
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)))))))",
|
||||
"(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))",
|
||||
"(def! not (fn* (cond) (if cond false true)))",
|
||||
"(def! load-file (fn* (filename) \
|
||||
(eval (read-string (str \"(do \" (slurp filename) \")\")))))",
|
||||
"(def! inc (fn* [x] (+ x 1)))",
|
||||
"(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))",
|
||||
"(def! *host-language* \"C++\")",
|
||||
};
|
||||
|
||||
|
@ -231,7 +231,6 @@ REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0
|
||||
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 "(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
argv = Mal::List.new
|
||||
REPL_ENV.set("*ARGV*", Mal::Type.new argv)
|
||||
|
@ -248,7 +248,6 @@ REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0
|
||||
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 "(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
argv = Mal::List.new
|
||||
REPL_ENV.set("*ARGV*", Mal::Type.new argv)
|
||||
|
@ -254,9 +254,6 @@ REPL_ENV.set("eval", Mal::Type.new ->(args : Array(Mal::Type)) { Mal.eval(args[0
|
||||
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 "(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! inc (fn* [x] (+ x 1)))"
|
||||
Mal.rep "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))"
|
||||
Mal.rep "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))"
|
||||
Mal.rep("(def! *host-language* \"crystal\")")
|
||||
|
||||
argv = Mal::List.new
|
||||
|
@ -227,7 +227,6 @@ namespace Mal {
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
RE("(load-file \"" + args[fileIdx] + "\")");
|
||||
|
@ -248,7 +248,6 @@ namespace Mal {
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
RE("(load-file \"" + args[fileIdx] + "\")");
|
||||
|
@ -249,9 +249,6 @@ namespace Mal {
|
||||
RE("(def! not (fn* (a) (if a false true)))");
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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)))))))");
|
||||
RE("(def! inc (fn* [x] (+ x 1)))");
|
||||
RE("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
|
||||
if (args.Length > fileIdx) {
|
||||
RE("(load-file \"" + args[fileIdx] + "\")");
|
||||
|
@ -263,7 +263,6 @@ void main(string[] args)
|
||||
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("(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);
|
||||
re("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -292,7 +292,6 @@ void main(string[] args)
|
||||
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("(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);
|
||||
re("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -294,9 +294,6 @@ void main(string[] args)
|
||||
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("(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);
|
||||
re("(def! inc (fn* [x] (+ x 1)))", repl_env);
|
||||
re("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", repl_env);
|
||||
re("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))", repl_env);
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
@ -27,12 +27,6 @@ void setupEnv(List<String> argv) {
|
||||
" (nth xs 1) "
|
||||
" (throw \"odd number of forms to cond\")) "
|
||||
" (cons 'cond (rest (rest xs)))))))");
|
||||
rep("(defmacro! or "
|
||||
" (fn* (& xs) (if (empty? xs) nil "
|
||||
" (if (= 1 (count xs)) "
|
||||
" (first xs) "
|
||||
" `(let* (or_FIXME ~(first xs)) "
|
||||
" (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
}
|
||||
|
||||
/// Returns `true` if [ast] is a macro call.
|
||||
|
@ -27,12 +27,6 @@ void setupEnv(List<String> argv) {
|
||||
" (nth xs 1) "
|
||||
" (throw \"odd number of forms to cond\")) "
|
||||
" (cons 'cond (rest (rest xs)))))))");
|
||||
rep("(defmacro! or "
|
||||
" (fn* (& xs) (if (empty? xs) nil "
|
||||
" (if (= 1 (count xs)) "
|
||||
" (first xs) "
|
||||
" `(let* (or_FIXME ~(first xs)) "
|
||||
" (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
}
|
||||
|
||||
/// Returns `true` if [ast] is a macro call.
|
||||
|
@ -29,20 +29,6 @@ void setupEnv(List<String> argv) {
|
||||
" (nth xs 1) "
|
||||
" (throw \"odd number of forms to cond\")) "
|
||||
" (cons 'cond (rest (rest xs)))))))");
|
||||
rep("(def! inc (fn* [x] (+ x 1)))");
|
||||
rep("(def! gensym"
|
||||
" (let* [counter (atom 0)]"
|
||||
" (fn* []"
|
||||
" (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
rep("(defmacro! or "
|
||||
" (fn* (& xs) "
|
||||
" (if (empty? xs) "
|
||||
" nil "
|
||||
" (if (= 1 (count xs)) "
|
||||
" (first xs) "
|
||||
" (let* (condvar (gensym)) "
|
||||
" `(let* (~condvar ~(first xs)) "
|
||||
" (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
}
|
||||
|
||||
/// Returns `true` if [ast] is a macro call.
|
||||
|
@ -247,9 +247,6 @@
|
||||
<span class=file>step9_try.EXT</span>:
|
||||
<span class=function>EVAL</span>(<span class=var>ast</span>, <span class=var>env</span>):
|
||||
- set <span class=malsym>*host-language*</span> in <span class=var>repl_env</span> to host language name
|
||||
- <span class=malsym>inc</span>: define (using <span class=function>rep</span>()) a function incrementing an integer
|
||||
- <span class=malsym>gensym</span>: define using <span class=function>rep</span>()), return unique symbol
|
||||
- <span class=malsym>or</span>: use <span class=malsym>gensym</span> to fix <span class=malsym>or</span> macro
|
||||
<span class=function>main</span>(<span class=var>args</span>): <span class=function>rep</span>(<span class=string>"(println (str \"Mal [\" <span class=malsym>*host-language*</span> \"]\"))"</span>)
|
||||
</code></pre>
|
||||
</td>
|
||||
|
@ -181,9 +181,7 @@
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
;; C-d throws an error
|
||||
|
@ -197,9 +197,7 @@
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
;; C-d throws an error
|
||||
|
@ -198,12 +198,7 @@
|
||||
|
||||
(rep "(def! not (fn* (a) (if a false true)))")
|
||||
(rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
|
||||
(rep "(def! inc (fn* [x] (+ x 1)))")
|
||||
(rep "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
(defun readln (prompt)
|
||||
;; C-d throws an error
|
||||
|
@ -42,17 +42,6 @@ defmodule Mix.Tasks.Step8Macros do
|
||||
(cons 'cond (rest (rest xs)))))))"
|
||||
""", env)
|
||||
|
||||
# or:
|
||||
read_eval_print("""
|
||||
(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
`(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
""", env)
|
||||
|
||||
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->
|
||||
eval(ast, env)
|
||||
end})
|
||||
|
@ -42,17 +42,6 @@ defmodule Mix.Tasks.Step9Try do
|
||||
(cons 'cond (rest (rest xs)))))))"
|
||||
""", env)
|
||||
|
||||
# or:
|
||||
read_eval_print("""
|
||||
(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
`(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
""", env)
|
||||
|
||||
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->
|
||||
eval(ast, env)
|
||||
end})
|
||||
|
@ -50,28 +50,6 @@ defmodule Mix.Tasks.StepAMal do
|
||||
(cons 'cond (rest (rest xs)))))))"
|
||||
""", env)
|
||||
|
||||
# gensym
|
||||
read_eval_print("(def! inc (fn* [x] (+ x 1)))", env)
|
||||
read_eval_print("""
|
||||
(def! gensym
|
||||
(let* [counter (atom 0)]
|
||||
(fn* []
|
||||
(symbol (str \"G__\" (swap! counter inc))))))
|
||||
""", env)
|
||||
|
||||
# or:
|
||||
read_eval_print("""
|
||||
(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
(let* (condvar (gensym))
|
||||
`(let* (~condvar ~(first xs))
|
||||
(if ~condvar ~condvar (or ~@(rest xs)))))))))
|
||||
""", env)
|
||||
|
||||
Mal.Env.set(env, "eval", %Function{value: fn [ast] ->
|
||||
eval(ast, env)
|
||||
end})
|
||||
|
@ -80,14 +80,6 @@ malInit =
|
||||
(nth xs 1)
|
||||
(throw "odd number of forms to cond"))
|
||||
(cons 'cond (rest (rest xs)))))))"""
|
||||
, """(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
`(let* (or_FIXME ~(first xs))
|
||||
(if or_FIXME or_FIXME (or ~@(rest xs))))))))"""
|
||||
]
|
||||
|
||||
|
||||
|
@ -80,14 +80,6 @@ malInit =
|
||||
(nth xs 1)
|
||||
(throw "odd number of forms to cond"))
|
||||
(cons 'cond (rest (rest xs)))))))"""
|
||||
, """(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
`(let* (or_FIXME ~(first xs))
|
||||
(if or_FIXME or_FIXME (or ~@(rest xs))))))))"""
|
||||
]
|
||||
|
||||
|
||||
|
@ -81,22 +81,6 @@ malInit =
|
||||
(nth xs 1)
|
||||
(throw "odd number of forms to cond"))
|
||||
(cons 'cond (rest (rest xs)))))))"""
|
||||
, """(def! inc (fn* [x] (+ x 1)))"""
|
||||
, """(def! gensym
|
||||
(let* [counter (atom 0)]
|
||||
(fn* []
|
||||
(symbol (str "G__" (swap! counter inc))))))"""
|
||||
, """(defmacro! or
|
||||
(fn* (& xs)
|
||||
(if (empty? xs)
|
||||
nil
|
||||
(if (= 1 (count xs))
|
||||
(first xs)
|
||||
(let* (condvar (gensym))
|
||||
`(let* (~condvar ~(first xs))
|
||||
(if ~condvar
|
||||
~condvar
|
||||
(or ~@(rest xs)))))))))"""
|
||||
]
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ init() ->
|
||||
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("(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),
|
||||
eval(read("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME \~(first xs)) (if or_FIXME or_FIXME (or \~@(rest xs))))))))"), Env),
|
||||
Env.
|
||||
|
||||
loop(Env) ->
|
||||
|
@ -20,7 +20,6 @@ init() ->
|
||||
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("(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),
|
||||
eval(read("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME \~(first xs)) (if or_FIXME or_FIXME (or \~@(rest xs))))))))"), Env),
|
||||
Env.
|
||||
|
||||
loop(Env) ->
|
||||
|
@ -22,9 +22,6 @@ init() ->
|
||||
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("(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),
|
||||
eval(read("(def! inc (fn* [x] (+ x 1)))"), Env),
|
||||
eval(read("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))"), Env),
|
||||
eval(read("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (\~condvar \~(first xs)) (if \~condvar \~condvar (or \~@(rest xs)))))))))"), Env),
|
||||
Env.
|
||||
|
||||
loop(Env) ->
|
||||
|
@ -128,7 +128,6 @@ env_set(repl_env, Symbol.for('*ARGV*'), [])
|
||||
REP('(def! not (fn* (a) (if a false true)))')
|
||||
REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))')
|
||||
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('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))')
|
||||
|
||||
if (process.argv.length > 2) {
|
||||
env_set(repl_env, Symbol.for('*ARGV*'), process.argv.slice(3))
|
||||
|
@ -139,7 +139,6 @@ env_set(repl_env, Symbol.for('*ARGV*'), [])
|
||||
REP('(def! not (fn* (a) (if a false true)))')
|
||||
REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))')
|
||||
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('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))')
|
||||
|
||||
if (process.argv.length > 2) {
|
||||
env_set(repl_env, Symbol.for('*ARGV*'), process.argv.slice(3))
|
||||
|
@ -140,9 +140,6 @@ REP('(def! *host-language* "ecmascript6")')
|
||||
REP('(def! not (fn* (a) (if a false true)))')
|
||||
REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))')
|
||||
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! inc (fn* [x] (+ x 1)))')
|
||||
REP('(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))')
|
||||
REP('(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))')
|
||||
|
||||
if (process.argv.length > 2) {
|
||||
env_set(repl_env, Symbol.for('*ARGV*'), process.argv.slice(3))
|
||||
|
@ -141,7 +141,6 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))
|
||||
(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)))))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
" string-lines harvest [ REP drop ] each
|
||||
|
||||
MAIN: main
|
||||
|
@ -153,7 +153,6 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))
|
||||
(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)))))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))
|
||||
" string-lines harvest [ REP drop ] each
|
||||
|
||||
MAIN: main
|
||||
|
@ -147,9 +147,6 @@ command-line get dup empty? [ rest ] unless "*ARGV*" pick set-at
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))
|
||||
(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! inc (fn* [x] (+ x 1)))
|
||||
(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))
|
||||
" string-lines harvest [ READ repl-env get EVAL drop ] each
|
||||
|
||||
MAIN: main
|
||||
|
@ -153,7 +153,6 @@ class Main
|
||||
REP("(def! not (fn* (a) (if a false true)))", repl_env)
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env)
|
||||
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_env)
|
||||
REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))", repl_env)
|
||||
|
||||
if (!args.isEmpty)
|
||||
{
|
||||
|
@ -165,7 +165,6 @@ class Main
|
||||
REP("(def! not (fn* (a) (if a false true)))", repl_env)
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env)
|
||||
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_env)
|
||||
REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))", repl_env)
|
||||
|
||||
if (!args.isEmpty)
|
||||
{
|
||||
|
@ -166,9 +166,6 @@ class Main
|
||||
REP("(def! not (fn* (a) (if a false true)))", repl_env)
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env)
|
||||
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_env)
|
||||
REP("(def! inc (fn* [x] (+ x 1)))", repl_env)
|
||||
REP("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", repl_env)
|
||||
REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))", repl_env)
|
||||
|
||||
if (!args.isEmpty)
|
||||
{
|
||||
|
@ -310,7 +310,6 @@ defcore swap! { argv argc -- val }
|
||||
s\" (def! not (fn* (x) (if x false true)))" rep 2drop
|
||||
s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop
|
||||
s\" (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 2drop
|
||||
s\" (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))" rep 2drop
|
||||
|
||||
: repl ( -- )
|
||||
begin
|
||||
|
@ -353,7 +353,6 @@ defcore map ( argv argc -- list )
|
||||
s\" (def! not (fn* (x) (if x false true)))" rep 2drop
|
||||
s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop
|
||||
s\" (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 2drop
|
||||
s\" (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))" rep 2drop
|
||||
|
||||
: repl ( -- )
|
||||
begin
|
||||
|
@ -361,9 +361,6 @@ s\" (def! *host-language* \"forth\")" rep 2drop
|
||||
s\" (def! not (fn* (x) (if x false true)))" rep 2drop
|
||||
s\" (def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" rep 2drop
|
||||
s\" (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 2drop
|
||||
s\" (def! inc (fn* [x] (+ x 1)))" rep 2drop
|
||||
s\" (def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))" rep 2drop
|
||||
s\" (defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))" rep 2drop
|
||||
|
||||
: repl ( -- )
|
||||
s\" (println (str \"Mal [\" *host-language* \"]\"))" rep 2drop
|
||||
|
@ -186,7 +186,6 @@ module REPL
|
||||
RE env """
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (slurp f)))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_ ~(first xs)) (if or_ or_ (or ~@(rest xs))))))))
|
||||
(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)))))))
|
||||
""" |> Seq.iter ignore
|
||||
|
||||
|
@ -206,7 +206,6 @@ module REPL
|
||||
RE env """
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (slurp f)))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_ ~(first xs)) (if or_ or_ (or ~@(rest xs))))))))
|
||||
(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)))))))
|
||||
""" |> Seq.iter ignore
|
||||
|
||||
|
@ -218,9 +218,6 @@ module REPL
|
||||
(def! not (fn* (a) (if a false true)))
|
||||
(def! load-file (fn* (f) (eval (read-string (slurp f)))))
|
||||
(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! inc (fn* [x] (+ x 1)))
|
||||
(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))
|
||||
(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))
|
||||
""" |> Seq.iter ignore
|
||||
|
||||
env
|
||||
|
@ -270,9 +270,7 @@ replEnv set: #'*ARGV*' value: (MALList new: argv).
|
||||
|
||||
MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv.
|
||||
MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv.
|
||||
|
||||
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)))))))' env: replEnv.
|
||||
MAL rep: '(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))' env: replEnv.
|
||||
|
||||
Smalltalk arguments notEmpty ifTrue: [
|
||||
MAL rep: '(load-file "', Smalltalk arguments first, '")' env: replEnv
|
||||
|
@ -291,9 +291,7 @@ replEnv set: #'*ARGV*' value: (MALList new: argv).
|
||||
|
||||
MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv.
|
||||
MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv.
|
||||
|
||||
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)))))))' env: replEnv.
|
||||
MAL rep: '(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))' env: replEnv.
|
||||
|
||||
Smalltalk arguments notEmpty ifTrue: [
|
||||
MAL rep: '(load-file "', Smalltalk arguments first, '")' env: replEnv
|
||||
|
@ -292,11 +292,7 @@ replEnv set: #'*host-language*' value: (MALString new: 'smalltalk').
|
||||
|
||||
MAL rep: '(def! not (fn* (a) (if a false true)))' env: replEnv.
|
||||
MAL rep: '(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))' env: replEnv.
|
||||
|
||||
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)))))))' env: replEnv.
|
||||
MAL rep: '(def! inc (fn* [x] (+ x 1)))' env: replEnv.
|
||||
MAL rep: '(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))' env: replEnv.
|
||||
MAL rep: '(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))' env: replEnv.
|
||||
|
||||
Smalltalk arguments notEmpty ifTrue: [
|
||||
MAL rep: '(load-file "', Smalltalk arguments first, '")' env: replEnv
|
||||
|
@ -311,7 +311,6 @@ func main() {
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
// called with mal script to load and eval
|
||||
if len(os.Args) > 1 {
|
||||
|
@ -339,7 +339,6 @@ func main() {
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
// called with mal script to load and eval
|
||||
if len(os.Args) > 1 {
|
||||
|
@ -340,9 +340,6 @@ func main() {
|
||||
rep("(def! not (fn* (a) (if a false true)))")
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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! inc (fn* [x] (+ x 1)))")
|
||||
rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
// called with mal script to load and eval
|
||||
if len(os.Args) > 1 {
|
||||
|
@ -150,7 +150,6 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List)
|
||||
REP("(def! not (fn* (a) (if a false true)))")
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
|
||||
if (this.args.size() > 0) {
|
||||
|
@ -168,7 +168,6 @@ repl_env.set(new MalSymbol("*ARGV*"), this.args as List)
|
||||
REP("(def! not (fn* (a) (if a false true)))")
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
|
||||
if (this.args.size() > 0) {
|
||||
|
@ -169,10 +169,6 @@ REP("(def! *host-language* \"groovy\")")
|
||||
REP("(def! not (fn* (a) (if a false true)))")
|
||||
REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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! inc (fn* [x] (+ x 1)))");
|
||||
REP("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
|
||||
|
||||
if (this.args.size() > 0) {
|
||||
repl_env.set(new MalSymbol("*ARGV*"), this.args.drop(1) as List)
|
||||
|
@ -163,7 +163,6 @@
|
||||
(EVAL-string "(def! not (fn* (x) (if x false true)))")
|
||||
(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(EVAL-string "(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)))))))")
|
||||
(EVAL-string "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(let ((args (cdr (command-line))))
|
||||
(cond
|
||||
|
@ -186,7 +186,6 @@
|
||||
(EVAL-string "(def! not (fn* (x) (if x false true)))")
|
||||
(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(EVAL-string "(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)))))))")
|
||||
(EVAL-string "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(let ((args (cdr (command-line))))
|
||||
(cond
|
||||
|
@ -183,9 +183,6 @@
|
||||
(EVAL-string "(def! not (fn* (x) (if x false true)))")
|
||||
(EVAL-string "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(EVAL-string "(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)))))))")
|
||||
(EVAL-string "(def! inc (fn* [x] (+ x 1)))")
|
||||
(EVAL-string "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
(EVAL-string "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
(EVAL-string "(def! *host-language* \"guile\")")
|
||||
|
||||
(let ((args (cdr (command-line))))
|
||||
|
@ -202,7 +202,6 @@ main = do
|
||||
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) \")\")))))"
|
||||
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)))))))"
|
||||
re repl_env "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
case args of
|
||||
script : scriptArgs -> do
|
||||
|
@ -213,7 +213,6 @@ main = do
|
||||
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) \")\")))))"
|
||||
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)))))))"
|
||||
re repl_env "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))"
|
||||
|
||||
case args of
|
||||
script : scriptArgs -> do
|
||||
|
@ -214,9 +214,6 @@ main = do
|
||||
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) \")\")))))"
|
||||
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)))))))"
|
||||
re repl_env "(def! inc (fn* [x] (+ x 1)))"
|
||||
re repl_env "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))"
|
||||
re repl_env "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))"
|
||||
|
||||
case args of
|
||||
script : scriptArgs -> do
|
||||
|
@ -192,7 +192,6 @@ class Step8_macros {
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
|
||||
if (cmdargs.length > 0) {
|
||||
|
@ -214,7 +214,6 @@ class Step9_try {
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))");
|
||||
|
||||
|
||||
if (cmdargs.length > 0) {
|
||||
|
@ -215,9 +215,6 @@ class StepA_mal {
|
||||
rep("(def! not (fn* (a) (if a false true)))");
|
||||
rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))");
|
||||
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! inc (fn* [x] (+ x 1)))");
|
||||
rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))");
|
||||
rep("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))");
|
||||
|
||||
|
||||
if (cmdargs.length > 0) {
|
||||
|
@ -159,7 +159,6 @@
|
||||
(REP "(def! not (fn* [a] (if a false true)))")
|
||||
(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defmain [&rest args]
|
||||
(if (>= (len args) 2)
|
||||
|
@ -171,7 +171,6 @@
|
||||
(REP "(def! not (fn* [a] (if a false true)))")
|
||||
(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(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 "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
(defmain [&rest args]
|
||||
(if (>= (len args) 2)
|
||||
|
@ -171,9 +171,6 @@
|
||||
(REP "(def! *host-language* \"Hy\")")
|
||||
(REP "(def! not (fn* [a] (if a false true)))")
|
||||
(REP "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
(REP "(def! inc (fn* [x] (+ x 1)))")
|
||||
(REP "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
(REP "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
(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)))))))")
|
||||
|
||||
(defmain [&rest args]
|
||||
|
@ -126,7 +126,6 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2)))
|
||||
RE("(def! not (fn* (a) (if a false true)))")
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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)))))))")
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
if(System args size > 1,
|
||||
REP("(load-file \"" .. (System args at(1)) .. "\")")
|
||||
|
@ -137,7 +137,6 @@ repl_env set(MalSymbol with("*ARGV*"), MalList with(System args slice(2)))
|
||||
RE("(def! not (fn* (a) (if a false true)))")
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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)))))))")
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) `(let* (or_FIXME ~(first xs)) (if or_FIXME or_FIXME (or ~@(rest xs))))))))")
|
||||
|
||||
if(System args size > 1,
|
||||
REP("(load-file \"" .. (System args at(1)) .. "\")")
|
||||
|
@ -138,9 +138,6 @@ RE("(def! *host-language* \"io\")")
|
||||
RE("(def! not (fn* (a) (if a false true)))")
|
||||
RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))")
|
||||
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)))))))")
|
||||
RE("(def! inc (fn* [x] (+ x 1)))")
|
||||
RE("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))")
|
||||
RE("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (condvar (gensym)) `(let* (~condvar ~(first xs)) (if ~condvar ~condvar (or ~@(rest xs)))))))))")
|
||||
|
||||
if(System args size > 1,
|
||||
REP("(load-file \"" .. (System args at(1)) .. "\")")
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user