From 26ced15b31c6ebfd77c7297a7f8d346ff08c3f9b Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez Date: Wed, 22 May 2019 20:45:57 +0200 Subject: [PATCH] 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). --- ada.2/step8_macros.adb | 7 +---- ada.2/step9_try.adb | 7 +---- ada.2/stepa_mal.adb | 9 ------ ada/step8_macros.adb | 1 - ada/step9_try.adb | 1 - ada/stepa_mal.adb | 3 -- awk/step8_macros.awk | 1 - awk/step9_try.awk | 1 - awk/stepA_mal.awk | 3 -- bash/step8_macros.sh | 1 - bash/step9_try.sh | 1 - bash/stepA_mal.sh | 3 -- basic/step8_macros.in.bas | 4 --- basic/step9_try.in.bas | 4 --- basic/stepA_mal.in.bas | 12 -------- bbc-basic/step8_macros.bbc | 1 - bbc-basic/step9_try.bbc | 1 - bbc-basic/stepA_mal.bbc | 3 -- c/step8_macros.c | 1 - c/step9_try.c | 1 - c/stepA_mal.c | 3 -- chuck/step8_macros.ck | 2 -- chuck/step9_try.ck | 2 -- chuck/stepA_mal.ck | 5 ---- clojure/src/mal/step8_macros.cljc | 1 - clojure/src/mal/step9_try.cljc | 1 - clojure/src/mal/stepA_mal.cljc | 3 -- coffee/step8_macros.coffee | 1 - coffee/step9_try.coffee | 1 - coffee/stepA_mal.coffee | 3 -- common-lisp/src/step8_macros.lisp | 1 - common-lisp/src/step9_try.lisp | 1 - common-lisp/src/stepA_mal.lisp | 3 -- cpp/step8_macros.cpp | 1 - cpp/step9_try.cpp | 1 - cpp/stepA_mal.cpp | 3 -- crystal/step8_macros.cr | 1 - crystal/step9_try.cr | 1 - crystal/stepA_mal.cr | 3 -- cs/step8_macros.cs | 1 - cs/step9_try.cs | 1 - cs/stepA_mal.cs | 3 -- d/step8_macros.d | 1 - d/step9_try.d | 1 - d/stepA_mal.d | 3 -- dart/step8_macros.dart | 6 ---- dart/step9_try.dart | 6 ---- dart/stepA_mal.dart | 14 --------- docs/cheatsheet.html | 3 -- elisp/step8_macros.el | 2 -- elisp/step9_try.el | 2 -- elisp/stepA_mal.el | 5 ---- elixir/lib/mix/tasks/step8_macros.ex | 11 ------- elixir/lib/mix/tasks/step9_try.ex | 11 ------- elixir/lib/mix/tasks/stepA_mal.ex | 22 -------------- elm/step8_macros.elm | 8 ----- elm/step9_try.elm | 8 ----- elm/stepA_mal.elm | 16 ---------- erlang/src/step8_macros.erl | 1 - erlang/src/step9_try.erl | 1 - erlang/src/stepA_mal.erl | 3 -- es6/step8_macros.mjs | 1 - es6/step9_try.mjs | 1 - es6/stepA_mal.mjs | 3 -- factor/step8_macros/step8_macros.factor | 1 - factor/step9_try/step9_try.factor | 1 - factor/stepA_mal/stepA_mal.factor | 3 -- fantom/src/step8_macros/fan/main.fan | 1 - fantom/src/step9_try/fan/main.fan | 1 - fantom/src/stepA_mal/fan/main.fan | 3 -- forth/step8_macros.fs | 1 - forth/step9_try.fs | 1 - forth/stepA_mal.fs | 3 -- fsharp/step8_macros.fs | 1 - fsharp/step9_try.fs | 1 - fsharp/stepA_mal.fs | 3 -- gnu-smalltalk/step8_macros.st | 2 -- gnu-smalltalk/step9_try.st | 2 -- gnu-smalltalk/stepA_mal.st | 4 --- go/src/step8_macros/step8_macros.go | 1 - go/src/step9_try/step9_try.go | 1 - go/src/stepA_mal/stepA_mal.go | 3 -- groovy/step8_macros.groovy | 1 - groovy/step9_try.groovy | 1 - groovy/stepA_mal.groovy | 4 --- guile/step8_macros.scm | 1 - guile/step9_try.scm | 1 - guile/stepA_mal.scm | 3 -- haskell/step8_macros.hs | 1 - haskell/step9_try.hs | 1 - haskell/stepA_mal.hs | 3 -- haxe/Step8_macros.hx | 1 - haxe/Step9_try.hx | 1 - haxe/StepA_mal.hx | 3 -- hy/step8_macros.hy | 1 - hy/step9_try.hy | 1 - hy/stepA_mal.hy | 3 -- io/step8_macros.io | 1 - io/step9_try.io | 1 - io/stepA_mal.io | 3 -- java/src/main/java/mal/step8_macros.java | 1 - java/src/main/java/mal/step9_try.java | 1 - java/src/main/java/mal/stepA_mal.java | 3 -- js/step8_macros.js | 1 - js/step9_try.js | 1 - js/stepA_mal.js | 3 -- julia/step8_macros.jl | 1 - julia/step9_try.jl | 1 - julia/stepA_mal.jl | 3 -- kotlin/src/mal/step8_macros.kt | 1 - kotlin/src/mal/step9_try.kt | 1 - kotlin/src/mal/stepA_mal.kt | 3 -- lib/perf.mal | 4 ++- lib/test_cascade.mal | 18 ++++++++++++ lib/trivial.mal | 10 +++++++ livescript/step8_macros.ls | 11 ------- livescript/step9_try.ls | 11 ------- livescript/stepA_mal.ls | 19 ------------ logo/step8_macros.lg | 1 - logo/step9_try.lg | 1 - logo/stepA_mal.lg | 3 -- lua/step8_macros.lua | 1 - lua/step9_try.lua | 1 - lua/stepA_mal.lua | 3 -- make/step8_macros.mk | 1 - make/step9_try.mk | 1 - make/stepA_mal.mk | 3 -- mal/step8_macros.mal | 1 - mal/step9_try.mal | 1 - mal/stepA_mal.mal | 3 -- matlab/step8_macros.m | 1 - matlab/step9_try.m | 1 - matlab/stepA_mal.m | 3 -- miniMAL/step8_macros.json | 1 - miniMAL/step9_try.json | 1 - miniMAL/stepA_mal.json | 3 -- nasm/step8_macros.asm | 1 - nasm/step9_try.asm | 1 - nasm/stepA_mal.asm | 3 -- nim/step8_macros.nim | 1 - nim/step9_try.nim | 1 - nim/stepA_mal.nim | 3 -- objc/step8_macros.m | 1 - objc/step9_try.m | 1 - objc/stepA_mal.m | 3 -- objpascal/step8_macros.pas | 1 - objpascal/step9_try.pas | 1 - objpascal/stepA_mal.pas | 3 -- ocaml/step8_macros.ml | 1 - ocaml/step9_try.ml | 1 - ocaml/stepA_mal.ml | 3 -- perl/step8_macros.pl | 1 - perl/step9_try.pl | 1 - perl/stepA_mal.pl | 4 --- perl6/step8_macros.pl | 1 - perl6/step9_try.pl | 1 - perl6/stepA_mal.pl | 3 -- php/step8_macros.php | 1 - php/step9_try.php | 1 - php/stepA_mal.php | 3 -- picolisp/step8_macros.l | 2 +- picolisp/step9_try.l | 1 - picolisp/stepA_mal.l | 4 --- plpgsql/step8_macros.sql | 1 - plpgsql/step9_try.sql | 1 - plpgsql/stepA_mal.sql | 3 -- plsql/step8_macros.sql | 1 - plsql/step9_try.sql | 1 - plsql/stepA_mal.sql | 3 -- powershell/step8_macros.ps1 | 1 - powershell/step9_try.ps1 | 1 - powershell/stepA_mal.ps1 | 3 -- process/guide.md | 37 ++++-------------------- process/step8_macros.txt | 1 - process/step9_try.txt | 1 - process/stepA_mal.txt | 3 -- ps/step8_macros.ps | 1 - ps/step9_try.ps | 1 - ps/stepA_mal.ps | 3 -- python/step8_macros.py | 1 - python/step9_try.py | 1 - python/stepA_mal.py | 3 -- r/step8_macros.r | 1 - r/step9_try.r | 1 - r/stepA_mal.r | 3 -- racket/step8_macros.rkt | 1 - racket/step9_try.rkt | 1 - racket/stepA_mal.rkt | 3 -- rexx/step8_macros.rexx | 1 - rexx/step9_try.rexx | 1 - rexx/stepA_mal.rexx | 3 -- rpython/step8_macros.py | 1 - rpython/step9_try.py | 1 - rpython/stepA_mal.py | 3 -- ruby/step8_macros.rb | 1 - ruby/step9_try.rb | 1 - ruby/stepA_mal.rb | 3 -- rust/step8_macros.rs | 1 - rust/step9_try.rs | 1 - rust/stepA_mal.rs | 3 -- scala/step8_macros.scala | 1 - scala/step9_try.scala | 1 - scala/stepA_mal.scala | 3 -- scheme/step8_macros.scm | 2 -- scheme/step9_try.scm | 2 -- scheme/stepA_mal.scm | 5 ---- skew/step8_macros.sk | 1 - skew/step9_try.sk | 1 - skew/stepA_mal.sk | 3 -- swift/step8_macros.swift | 2 -- swift/step9_try.swift | 2 -- swift/stepA_mal.swift | 4 --- swift3/Sources/step8_macros/main.swift | 1 - swift3/Sources/step9_try/main.swift | 1 - swift3/Sources/stepA_mal/main.swift | 3 -- swift4/Sources/step8_macros/main.swift | 1 - swift4/Sources/step9_try/main.swift | 1 - swift4/Sources/stepA_mal/main.swift | 3 -- tcl/step8_macros.tcl | 1 - tcl/step9_try.tcl | 1 - tcl/stepA_mal.tcl | 3 -- tests/lib/test_cascade.mal | 18 ++++++++++++ tests/lib/trivial.mal | 4 +++ tests/step8_macros.mal | 22 ++------------ tests/step9_try.mal | 4 +-- tests/stepA_mal.mal | 12 -------- ts/step8_macros.ts | 1 - ts/step9_try.ts | 1 - ts/stepA_mal.ts | 3 -- vala/step8_macros.vala | 1 - vala/step9_try.vala | 1 - vala/stepA_mal.vala | 3 -- vb/step8_macros.vb | 1 - vb/step9_try.vb | 1 - vb/stepA_mal.vb | 3 -- vhdl/step8_macros.vhdl | 1 - vhdl/step9_try.vhdl | 1 - vhdl/stepA_mal.vhdl | 3 -- vimscript/step8_macros.vim | 1 - vimscript/step9_try.vim | 1 - vimscript/stepA_mal.vim | 3 -- wasm/step8_macros.wam | 1 - wasm/step9_try.wam | 1 - wasm/stepA_mal.wam | 3 -- yorick/step8_macros.i | 1 - yorick/step9_try.i | 1 - yorick/stepA_mal.i | 3 -- 247 files changed, 65 insertions(+), 640 deletions(-) diff --git a/ada.2/step8_macros.adb b/ada.2/step8_macros.adb index 3786b8ed..4e9db3ec 100644 --- a/ada.2/step8_macros.adb +++ b/ada.2/step8_macros.adb @@ -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 diff --git a/ada.2/step9_try.adb b/ada.2/step9_try.adb index bc26dd0f..162eec10 100644 --- a/ada.2/step9_try.adb +++ b/ada.2/step9_try.adb @@ -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 diff --git a/ada.2/stepa_mal.adb b/ada.2/stepa_mal.adb index 0c665904..ba52c2c0 100644 --- a/ada.2/stepa_mal.adb +++ b/ada.2/stepa_mal.adb @@ -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 diff --git a/ada/step8_macros.adb b/ada/step8_macros.adb index 25cc8f42..40e4624c 100644 --- a/ada/step8_macros.adb +++ b/ada/step8_macros.adb @@ -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. diff --git a/ada/step9_try.adb b/ada/step9_try.adb index bd7fcd5c..fcbba5c5 100644 --- a/ada/step9_try.adb +++ b/ada/step9_try.adb @@ -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. diff --git a/ada/stepa_mal.adb b/ada/stepa_mal.adb index 1f1c049a..b0c9c040 100644 --- a/ada/stepa_mal.adb +++ b/ada/stepa_mal.adb @@ -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. diff --git a/awk/step8_macros.awk b/awk/step8_macros.awk index 50a7fde3..85fe014c 100644 --- a/awk/step8_macros.awk +++ b/awk/step8_macros.awk @@ -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) diff --git a/awk/step9_try.awk b/awk/step9_try.awk index 79e9ed1a..18583c67 100644 --- a/awk/step9_try.awk +++ b/awk/step9_try.awk @@ -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) diff --git a/awk/stepA_mal.awk b/awk/stepA_mal.awk index 8e7fae0d..ce5773b5 100644 --- a/awk/stepA_mal.awk +++ b/awk/stepA_mal.awk @@ -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) diff --git a/bash/step8_macros.sh b/bash/step8_macros.sh index d86cdd64..72b010da 100755 --- a/bash/step8_macros.sh +++ b/bash/step8_macros.sh @@ -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 diff --git a/bash/step9_try.sh b/bash/step9_try.sh index 7567050a..29fa329b 100755 --- a/bash/step9_try.sh +++ b/bash/step9_try.sh @@ -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 diff --git a/bash/stepA_mal.sh b/bash/stepA_mal.sh index d3df641b..e414b7ab 100755 --- a/bash/stepA_mal.sh +++ b/bash/stepA_mal.sh @@ -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 diff --git a/basic/step8_macros.in.bas b/basic/step8_macros.in.bas index c2c6f8ed..09397a18 100755 --- a/basic/step8_macros.in.bas +++ b/basic/step8_macros.in.bas @@ -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 diff --git a/basic/step9_try.in.bas b/basic/step9_try.in.bas index 26a18d77..d5e76c3c 100755 --- a/basic/step9_try.in.bas +++ b/basic/step9_try.in.bas @@ -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 diff --git a/basic/stepA_mal.in.bas b/basic/stepA_mal.in.bas index 9e6297dc..bfbef857 100755 --- a/basic/stepA_mal.in.bas +++ b/basic/stepA_mal.in.bas @@ -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 diff --git a/bbc-basic/step8_macros.bbc b/bbc-basic/step8_macros.bbc index a71954d0..5e9be483 100644 --- a/bbc-basic/step8_macros.bbc +++ b/bbc-basic/step8_macros.bbc @@ -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$ diff --git a/bbc-basic/step9_try.bbc b/bbc-basic/step9_try.bbc index 278556b3..f6524e3a 100644 --- a/bbc-basic/step9_try.bbc +++ b/bbc-basic/step9_try.bbc @@ -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$ diff --git a/bbc-basic/stepA_mal.bbc b/bbc-basic/stepA_mal.bbc index 062a7fc4..44c990cb 100644 --- a/bbc-basic/stepA_mal.bbc +++ b/bbc-basic/stepA_mal.bbc @@ -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 diff --git a/c/step8_macros.c b/c/step8_macros.c index 335642ba..5dede971 100644 --- a/c/step8_macros.c +++ b/c/step8_macros.c @@ -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[]) diff --git a/c/step9_try.c b/c/step9_try.c index 9c555aca..c4d262fe 100644 --- a/c/step9_try.c +++ b/c/step9_try.c @@ -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[]) diff --git a/c/stepA_mal.c b/c/stepA_mal.c index 4960cb51..2c8f6b0d 100644 --- a/c/stepA_mal.c +++ b/c/stepA_mal.c @@ -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[]) diff --git a/chuck/step8_macros.ck b/chuck/step8_macros.ck index f52e0de4..5c185d91 100644 --- a/chuck/step8_macros.ck +++ b/chuck/step8_macros.ck @@ -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() { diff --git a/chuck/step9_try.ck b/chuck/step9_try.ck index 539d1d8f..ecc45d8b 100644 --- a/chuck/step9_try.ck +++ b/chuck/step9_try.ck @@ -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() { diff --git a/chuck/stepA_mal.ck b/chuck/stepA_mal.ck index 51d1cf47..afe6b8d7 100644 --- a/chuck/stepA_mal.ck +++ b/chuck/stepA_mal.ck @@ -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; diff --git a/clojure/src/mal/step8_macros.cljc b/clojure/src/mal/step8_macros.cljc index 9cf70991..d0d56741 100644 --- a/clojure/src/mal/step8_macros.cljc +++ b/clojure/src/mal/step8_macros.cljc @@ -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 [] diff --git a/clojure/src/mal/step9_try.cljc b/clojure/src/mal/step9_try.cljc index e6ff0671..fd172375 100644 --- a/clojure/src/mal/step9_try.cljc +++ b/clojure/src/mal/step9_try.cljc @@ -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 [] diff --git a/clojure/src/mal/stepA_mal.cljc b/clojure/src/mal/stepA_mal.cljc index 6cb5f3e9..5a26159a 100644 --- a/clojure/src/mal/stepA_mal.cljc +++ b/clojure/src/mal/stepA_mal.cljc @@ -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 [] diff --git a/coffee/step8_macros.coffee b/coffee/step8_macros.coffee index 3b552f8d..98319a10 100644 --- a/coffee/step8_macros.coffee +++ b/coffee/step8_macros.coffee @@ -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..] diff --git a/coffee/step9_try.coffee b/coffee/step9_try.coffee index d5bbe010..71d479ed 100644 --- a/coffee/step9_try.coffee +++ b/coffee/step9_try.coffee @@ -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..] diff --git a/coffee/stepA_mal.coffee b/coffee/stepA_mal.coffee index 5a18714e..7f0030b3 100644 --- a/coffee/stepA_mal.coffee +++ b/coffee/stepA_mal.coffee @@ -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..] diff --git a/common-lisp/src/step8_macros.lisp b/common-lisp/src/step8_macros.lisp index e27ac6cc..ab75d9c6 100644 --- a/common-lisp/src/step8_macros.lisp +++ b/common-lisp/src/step8_macros.lisp @@ -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) diff --git a/common-lisp/src/step9_try.lisp b/common-lisp/src/step9_try.lisp index 87cc341f..d8bd04d8 100644 --- a/common-lisp/src/step9_try.lisp +++ b/common-lisp/src/step9_try.lisp @@ -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) diff --git a/common-lisp/src/stepA_mal.lisp b/common-lisp/src/stepA_mal.lisp index c9d7c334..adb17bfb 100644 --- a/common-lisp/src/stepA_mal.lisp +++ b/common-lisp/src/stepA_mal.lisp @@ -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) diff --git a/cpp/step8_macros.cpp b/cpp/step8_macros.cpp index 32d450de..183039d2 100644 --- a/cpp/step8_macros.cpp +++ b/cpp/step8_macros.cpp @@ -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) \")\")))))", diff --git a/cpp/step9_try.cpp b/cpp/step9_try.cpp index 7f776bd6..ea9f8ce5 100644 --- a/cpp/step9_try.cpp +++ b/cpp/step9_try.cpp @@ -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) \")\")))))", diff --git a/cpp/stepA_mal.cpp b/cpp/stepA_mal.cpp index 93a6f1d9..15ab8192 100644 --- a/cpp/stepA_mal.cpp +++ b/cpp/stepA_mal.cpp @@ -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++\")", }; diff --git a/crystal/step8_macros.cr b/crystal/step8_macros.cr index cca37102..d118c15f 100755 --- a/crystal/step8_macros.cr +++ b/crystal/step8_macros.cr @@ -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) diff --git a/crystal/step9_try.cr b/crystal/step9_try.cr index 5d63bc85..455c31e1 100755 --- a/crystal/step9_try.cr +++ b/crystal/step9_try.cr @@ -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) diff --git a/crystal/stepA_mal.cr b/crystal/stepA_mal.cr index 701ffb6e..2d7b39b8 100755 --- a/crystal/stepA_mal.cr +++ b/crystal/stepA_mal.cr @@ -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 diff --git a/cs/step8_macros.cs b/cs/step8_macros.cs index 3ec240a3..6c1d7062 100644 --- a/cs/step8_macros.cs +++ b/cs/step8_macros.cs @@ -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] + "\")"); diff --git a/cs/step9_try.cs b/cs/step9_try.cs index 0e37436a..0a8f746f 100644 --- a/cs/step9_try.cs +++ b/cs/step9_try.cs @@ -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] + "\")"); diff --git a/cs/stepA_mal.cs b/cs/stepA_mal.cs index 1f14be86..70fc0d22 100644 --- a/cs/stepA_mal.cs +++ b/cs/stepA_mal.cs @@ -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] + "\")"); diff --git a/d/step8_macros.d b/d/step8_macros.d index 48b3d2b2..a39ff89d 100644 --- a/d/step8_macros.d +++ b/d/step8_macros.d @@ -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) { diff --git a/d/step9_try.d b/d/step9_try.d index 9070dfa1..054b38e1 100644 --- a/d/step9_try.d +++ b/d/step9_try.d @@ -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) { diff --git a/d/stepA_mal.d b/d/stepA_mal.d index a669dde7..31658e53 100644 --- a/d/stepA_mal.d +++ b/d/stepA_mal.d @@ -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) { diff --git a/dart/step8_macros.dart b/dart/step8_macros.dart index de9fbbf0..a8baada8 100644 --- a/dart/step8_macros.dart +++ b/dart/step8_macros.dart @@ -27,12 +27,6 @@ void setupEnv(List 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. diff --git a/dart/step9_try.dart b/dart/step9_try.dart index 09bedbeb..8d048375 100644 --- a/dart/step9_try.dart +++ b/dart/step9_try.dart @@ -27,12 +27,6 @@ void setupEnv(List 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. diff --git a/dart/stepA_mal.dart b/dart/stepA_mal.dart index a1bacce6..aee59590 100644 --- a/dart/stepA_mal.dart +++ b/dart/stepA_mal.dart @@ -29,20 +29,6 @@ void setupEnv(List 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. diff --git a/docs/cheatsheet.html b/docs/cheatsheet.html index f3124f3c..28719052 100644 --- a/docs/cheatsheet.html +++ b/docs/cheatsheet.html @@ -247,9 +247,6 @@ step9_try.EXT: EVAL(ast, env): - set *host-language* in repl_env to host language name - - inc: define (using rep()) a function incrementing an integer - - gensym: define using rep()), return unique symbol - - or: use gensym to fix or macro main(args): rep("(println (str \"Mal [\" *host-language* \"]\"))") diff --git a/elisp/step8_macros.el b/elisp/step8_macros.el index d9ed1da3..26c5f445 100644 --- a/elisp/step8_macros.el +++ b/elisp/step8_macros.el @@ -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 diff --git a/elisp/step9_try.el b/elisp/step9_try.el index 7dc47a96..289478d9 100644 --- a/elisp/step9_try.el +++ b/elisp/step9_try.el @@ -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 diff --git a/elisp/stepA_mal.el b/elisp/stepA_mal.el index c8a31e57..c4ae1cc4 100644 --- a/elisp/stepA_mal.el +++ b/elisp/stepA_mal.el @@ -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 diff --git a/elixir/lib/mix/tasks/step8_macros.ex b/elixir/lib/mix/tasks/step8_macros.ex index abb6e6df..45edae19 100644 --- a/elixir/lib/mix/tasks/step8_macros.ex +++ b/elixir/lib/mix/tasks/step8_macros.ex @@ -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}) diff --git a/elixir/lib/mix/tasks/step9_try.ex b/elixir/lib/mix/tasks/step9_try.ex index b1b94c8e..917b2a2e 100644 --- a/elixir/lib/mix/tasks/step9_try.ex +++ b/elixir/lib/mix/tasks/step9_try.ex @@ -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}) diff --git a/elixir/lib/mix/tasks/stepA_mal.ex b/elixir/lib/mix/tasks/stepA_mal.ex index b5665ba4..340be5a3 100644 --- a/elixir/lib/mix/tasks/stepA_mal.ex +++ b/elixir/lib/mix/tasks/stepA_mal.ex @@ -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}) diff --git a/elm/step8_macros.elm b/elm/step8_macros.elm index 023d1179..85d57ce9 100644 --- a/elm/step8_macros.elm +++ b/elm/step8_macros.elm @@ -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))))))))""" ] diff --git a/elm/step9_try.elm b/elm/step9_try.elm index 44b3180c..ed7d9f71 100644 --- a/elm/step9_try.elm +++ b/elm/step9_try.elm @@ -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))))))))""" ] diff --git a/elm/stepA_mal.elm b/elm/stepA_mal.elm index fa0e4c03..2c7f72f7 100644 --- a/elm/stepA_mal.elm +++ b/elm/stepA_mal.elm @@ -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)))))))))""" ] diff --git a/erlang/src/step8_macros.erl b/erlang/src/step8_macros.erl index 8f7bccaf..07d0d5f9 100644 --- a/erlang/src/step8_macros.erl +++ b/erlang/src/step8_macros.erl @@ -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) -> diff --git a/erlang/src/step9_try.erl b/erlang/src/step9_try.erl index c35da92f..8211f76b 100644 --- a/erlang/src/step9_try.erl +++ b/erlang/src/step9_try.erl @@ -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) -> diff --git a/erlang/src/stepA_mal.erl b/erlang/src/stepA_mal.erl index 4ead8e9b..d4668fe4 100644 --- a/erlang/src/stepA_mal.erl +++ b/erlang/src/stepA_mal.erl @@ -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) -> diff --git a/es6/step8_macros.mjs b/es6/step8_macros.mjs index 5857c7e2..45195158 100644 --- a/es6/step8_macros.mjs +++ b/es6/step8_macros.mjs @@ -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)) diff --git a/es6/step9_try.mjs b/es6/step9_try.mjs index 73706c3d..7cc6e962 100644 --- a/es6/step9_try.mjs +++ b/es6/step9_try.mjs @@ -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)) diff --git a/es6/stepA_mal.mjs b/es6/stepA_mal.mjs index 936a787f..4ae066d8 100644 --- a/es6/stepA_mal.mjs +++ b/es6/stepA_mal.mjs @@ -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)) diff --git a/factor/step8_macros/step8_macros.factor b/factor/step8_macros/step8_macros.factor index 7dda02ed..330ccb70 100755 --- a/factor/step8_macros/step8_macros.factor +++ b/factor/step8_macros/step8_macros.factor @@ -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 diff --git a/factor/step9_try/step9_try.factor b/factor/step9_try/step9_try.factor index 92fae103..1a596c89 100755 --- a/factor/step9_try/step9_try.factor +++ b/factor/step9_try/step9_try.factor @@ -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 diff --git a/factor/stepA_mal/stepA_mal.factor b/factor/stepA_mal/stepA_mal.factor index 4f964dd3..622bc889 100755 --- a/factor/stepA_mal/stepA_mal.factor +++ b/factor/stepA_mal/stepA_mal.factor @@ -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 diff --git a/fantom/src/step8_macros/fan/main.fan b/fantom/src/step8_macros/fan/main.fan index 243295c4..73310b1e 100644 --- a/fantom/src/step8_macros/fan/main.fan +++ b/fantom/src/step8_macros/fan/main.fan @@ -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) { diff --git a/fantom/src/step9_try/fan/main.fan b/fantom/src/step9_try/fan/main.fan index 5a7332cc..b9f314df 100644 --- a/fantom/src/step9_try/fan/main.fan +++ b/fantom/src/step9_try/fan/main.fan @@ -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) { diff --git a/fantom/src/stepA_mal/fan/main.fan b/fantom/src/stepA_mal/fan/main.fan index c50e947d..72587905 100644 --- a/fantom/src/stepA_mal/fan/main.fan +++ b/fantom/src/stepA_mal/fan/main.fan @@ -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) { diff --git a/forth/step8_macros.fs b/forth/step8_macros.fs index bbdc4526..fffee717 100644 --- a/forth/step8_macros.fs +++ b/forth/step8_macros.fs @@ -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 diff --git a/forth/step9_try.fs b/forth/step9_try.fs index 07ee8b8b..d30afadb 100644 --- a/forth/step9_try.fs +++ b/forth/step9_try.fs @@ -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 diff --git a/forth/stepA_mal.fs b/forth/stepA_mal.fs index 994a9a0d..28979483 100644 --- a/forth/stepA_mal.fs +++ b/forth/stepA_mal.fs @@ -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 diff --git a/fsharp/step8_macros.fs b/fsharp/step8_macros.fs index f893f52b..644114b4 100644 --- a/fsharp/step8_macros.fs +++ b/fsharp/step8_macros.fs @@ -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 diff --git a/fsharp/step9_try.fs b/fsharp/step9_try.fs index 6bf6549e..c001836b 100644 --- a/fsharp/step9_try.fs +++ b/fsharp/step9_try.fs @@ -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 diff --git a/fsharp/stepA_mal.fs b/fsharp/stepA_mal.fs index f2d40c57..621657b2 100644 --- a/fsharp/stepA_mal.fs +++ b/fsharp/stepA_mal.fs @@ -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 diff --git a/gnu-smalltalk/step8_macros.st b/gnu-smalltalk/step8_macros.st index 602e4441..cd45f841 100644 --- a/gnu-smalltalk/step8_macros.st +++ b/gnu-smalltalk/step8_macros.st @@ -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 diff --git a/gnu-smalltalk/step9_try.st b/gnu-smalltalk/step9_try.st index 39022321..c5e22fcd 100644 --- a/gnu-smalltalk/step9_try.st +++ b/gnu-smalltalk/step9_try.st @@ -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 diff --git a/gnu-smalltalk/stepA_mal.st b/gnu-smalltalk/stepA_mal.st index dd8db1da..67dcd2de 100644 --- a/gnu-smalltalk/stepA_mal.st +++ b/gnu-smalltalk/stepA_mal.st @@ -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 diff --git a/go/src/step8_macros/step8_macros.go b/go/src/step8_macros/step8_macros.go index 4b20938b..9a8ffa6d 100644 --- a/go/src/step8_macros/step8_macros.go +++ b/go/src/step8_macros/step8_macros.go @@ -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 { diff --git a/go/src/step9_try/step9_try.go b/go/src/step9_try/step9_try.go index 7902889e..52f939a0 100644 --- a/go/src/step9_try/step9_try.go +++ b/go/src/step9_try/step9_try.go @@ -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 { diff --git a/go/src/stepA_mal/stepA_mal.go b/go/src/stepA_mal/stepA_mal.go index 60a29084..223f46d9 100644 --- a/go/src/stepA_mal/stepA_mal.go +++ b/go/src/stepA_mal/stepA_mal.go @@ -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 { diff --git a/groovy/step8_macros.groovy b/groovy/step8_macros.groovy index 24b1a90a..8ede17d8 100644 --- a/groovy/step8_macros.groovy +++ b/groovy/step8_macros.groovy @@ -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) { diff --git a/groovy/step9_try.groovy b/groovy/step9_try.groovy index c921bd6d..bef6e2c7 100644 --- a/groovy/step9_try.groovy +++ b/groovy/step9_try.groovy @@ -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) { diff --git a/groovy/stepA_mal.groovy b/groovy/stepA_mal.groovy index 14c01a3c..8485e40c 100644 --- a/groovy/stepA_mal.groovy +++ b/groovy/stepA_mal.groovy @@ -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) diff --git a/guile/step8_macros.scm b/guile/step8_macros.scm index 77f1a1ac..39c46895 100644 --- a/guile/step8_macros.scm +++ b/guile/step8_macros.scm @@ -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 diff --git a/guile/step9_try.scm b/guile/step9_try.scm index 83b90751..5aec65b1 100644 --- a/guile/step9_try.scm +++ b/guile/step9_try.scm @@ -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 diff --git a/guile/stepA_mal.scm b/guile/stepA_mal.scm index 17438a9e..894f1478 100644 --- a/guile/stepA_mal.scm +++ b/guile/stepA_mal.scm @@ -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)))) diff --git a/haskell/step8_macros.hs b/haskell/step8_macros.hs index 6c0c2ed5..411b4408 100644 --- a/haskell/step8_macros.hs +++ b/haskell/step8_macros.hs @@ -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 diff --git a/haskell/step9_try.hs b/haskell/step9_try.hs index c4cc6a5f..ab94c996 100644 --- a/haskell/step9_try.hs +++ b/haskell/step9_try.hs @@ -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 diff --git a/haskell/stepA_mal.hs b/haskell/stepA_mal.hs index ea903c8d..04a44a8e 100644 --- a/haskell/stepA_mal.hs +++ b/haskell/stepA_mal.hs @@ -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 diff --git a/haxe/Step8_macros.hx b/haxe/Step8_macros.hx index dc115bd7..0f63a64a 100644 --- a/haxe/Step8_macros.hx +++ b/haxe/Step8_macros.hx @@ -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) { diff --git a/haxe/Step9_try.hx b/haxe/Step9_try.hx index 07b7f060..13aa3208 100644 --- a/haxe/Step9_try.hx +++ b/haxe/Step9_try.hx @@ -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) { diff --git a/haxe/StepA_mal.hx b/haxe/StepA_mal.hx index bf548daa..958efce1 100644 --- a/haxe/StepA_mal.hx +++ b/haxe/StepA_mal.hx @@ -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) { diff --git a/hy/step8_macros.hy b/hy/step8_macros.hy index 7297a2a8..5089a201 100755 --- a/hy/step8_macros.hy +++ b/hy/step8_macros.hy @@ -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) diff --git a/hy/step9_try.hy b/hy/step9_try.hy index d436aa70..de2c9348 100755 --- a/hy/step9_try.hy +++ b/hy/step9_try.hy @@ -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) diff --git a/hy/stepA_mal.hy b/hy/stepA_mal.hy index f3c7ad68..42cd81dd 100755 --- a/hy/stepA_mal.hy +++ b/hy/stepA_mal.hy @@ -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] diff --git a/io/step8_macros.io b/io/step8_macros.io index b451019f..21acdc9f 100644 --- a/io/step8_macros.io +++ b/io/step8_macros.io @@ -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)) .. "\")") diff --git a/io/step9_try.io b/io/step9_try.io index 6c56b109..c547e218 100644 --- a/io/step9_try.io +++ b/io/step9_try.io @@ -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)) .. "\")") diff --git a/io/stepA_mal.io b/io/stepA_mal.io index 9dd4a56d..55e8911d 100644 --- a/io/stepA_mal.io +++ b/io/stepA_mal.io @@ -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)) .. "\")") diff --git a/java/src/main/java/mal/step8_macros.java b/java/src/main/java/mal/step8_macros.java index c2fec4f3..24d29208 100644 --- a/java/src/main/java/mal/step8_macros.java +++ b/java/src/main/java/mal/step8_macros.java @@ -233,7 +233,6 @@ public class step8_macros { 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))))))))"); Integer fileIdx = 0; if (args.length > 0 && args[0].equals("--raw")) { diff --git a/java/src/main/java/mal/step9_try.java b/java/src/main/java/mal/step9_try.java index 1262bd89..ba45f9f9 100644 --- a/java/src/main/java/mal/step9_try.java +++ b/java/src/main/java/mal/step9_try.java @@ -259,7 +259,6 @@ public class step9_try { 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))))))))"); Integer fileIdx = 0; if (args.length > 0 && args[0].equals("--raw")) { diff --git a/java/src/main/java/mal/stepA_mal.java b/java/src/main/java/mal/stepA_mal.java index 744ccc7e..bc964a69 100644 --- a/java/src/main/java/mal/stepA_mal.java +++ b/java/src/main/java/mal/stepA_mal.java @@ -260,9 +260,6 @@ public class stepA_mal { 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)))))))))"); Integer fileIdx = 0; if (args.length > 0 && args[0].equals("--raw")) { diff --git a/js/step8_macros.js b/js/step8_macros.js index 54e7a22a..fc090fe1 100644 --- a/js/step8_macros.js +++ b/js/step8_macros.js @@ -160,7 +160,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 (typeof process !== 'undefined' && process.argv.length > 2) { repl_env.set(types._symbol('*ARGV*'), process.argv.slice(3)); diff --git a/js/step9_try.js b/js/step9_try.js index 211e82ae..fc7c5f9d 100644 --- a/js/step9_try.js +++ b/js/step9_try.js @@ -171,7 +171,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 (typeof process !== 'undefined' && process.argv.length > 2) { repl_env.set(types._symbol('*ARGV*'), process.argv.slice(3)); diff --git a/js/stepA_mal.js b/js/stepA_mal.js index b997cff4..622248c2 100644 --- a/js/stepA_mal.js +++ b/js/stepA_mal.js @@ -172,9 +172,6 @@ rep("(def! *host-language* \"javascript\")") 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 (typeof process !== 'undefined' && process.argv.length > 2) { repl_env.set(types._symbol('*ARGV*'), process.argv.slice(3)); diff --git a/julia/step8_macros.jl b/julia/step8_macros.jl index e7b42c76..db10a846 100755 --- a/julia/step8_macros.jl +++ b/julia/step8_macros.jl @@ -145,7 +145,6 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) 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 length(ARGS) > 0 diff --git a/julia/step9_try.jl b/julia/step9_try.jl index 868069a2..166b4e0e 100755 --- a/julia/step9_try.jl +++ b/julia/step9_try.jl @@ -163,7 +163,6 @@ env_set(repl_env, symbol("*ARGV*"), ARGS[2:end]) 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 length(ARGS) > 0 diff --git a/julia/stepA_mal.jl b/julia/stepA_mal.jl index 9aed2a2d..32764a05 100755 --- a/julia/stepA_mal.jl +++ b/julia/stepA_mal.jl @@ -164,9 +164,6 @@ REP("(def! *host-language* \"julia\")") 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 length(ARGS) > 0 diff --git a/kotlin/src/mal/step8_macros.kt b/kotlin/src/mal/step8_macros.kt index 929ccfb2..8d223c5d 100644 --- a/kotlin/src/mal/step8_macros.kt +++ b/kotlin/src/mal/step8_macros.kt @@ -155,7 +155,6 @@ fun main(args: Array) { 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.any()) { rep("(load-file \"${args[0]}\")", repl_env) diff --git a/kotlin/src/mal/step9_try.kt b/kotlin/src/mal/step9_try.kt index 03d44f4e..722de183 100644 --- a/kotlin/src/mal/step9_try.kt +++ b/kotlin/src/mal/step9_try.kt @@ -171,7 +171,6 @@ fun main(args: Array) { 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.any()) { rep("(load-file \"${args[0]}\")", repl_env) diff --git a/kotlin/src/mal/stepA_mal.kt b/kotlin/src/mal/stepA_mal.kt index 32c3268f..93abe0fd 100644 --- a/kotlin/src/mal/stepA_mal.kt +++ b/kotlin/src/mal/stepA_mal.kt @@ -172,9 +172,6 @@ fun main(args: Array) { 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.any()) { rep("(load-file \"${args[0]}\")", repl_env) diff --git a/lib/perf.mal b/lib/perf.mal index c01f5177..a88b3413 100644 --- a/lib/perf.mal +++ b/lib/perf.mal @@ -1,5 +1,7 @@ ;; Mesure performances. +(load-file "../lib/trivial.mal") ; gensym inc + ;; Evaluate an expression, but report the time spent (defmacro! time (fn* (exp) @@ -19,7 +21,7 @@ (let* [start (time-ms) _ (fn) elapsed (- (time-ms) start) - iters (+ 1 last-iters) + iters (inc last-iters) new-acc-ms (+ acc-ms elapsed)] ;; (do (prn "new-acc-ms:" new-acc-ms "iters:" iters)) (if (>= new-acc-ms max-ms) diff --git a/lib/test_cascade.mal b/lib/test_cascade.mal index cabe5333..0e85a60f 100644 --- a/lib/test_cascade.mal +++ b/lib/test_cascade.mal @@ -1,5 +1,23 @@ ;; Iteration on evaluations interpreted as boolean values. +(load-file "../lib/trivial.mal") ; gensym + +;; `(cond test1 result1 test2 result2 .. testn resultn)` +;; is rewritten (in the step files) as +;; `(if test1 result1 (if test2 result2 (.. (if testn resultn nil))))` +;; It is common that `testn` is `"else"`, `:else`, `true` or similar. + +;; `(or x1 x2 .. xn x)` +;; is almost rewritten as +;; `(if x1 x1 (if x2 x2 (.. (if xn xn x))))` +;; except that each argument is evaluated at most once. +;; Without arguments, returns `nil`. +(defmacro! or (fn* [& xs] + (if (< (count xs) 2) + (first xs) + (let* [r (gensym)] + `(let* [~r ~(first xs)] (if ~r ~r (or ~@(rest xs)))))))) + ;; Conjonction of predicate values (pred x1) and .. and (pred xn) ;; Evaluate `pred x` for each `x` in turn. Return `false` if a result ;; is `nil` or `false`, without evaluating the predicate for the diff --git a/lib/trivial.mal b/lib/trivial.mal index 8c4f6b6b..8ae32020 100644 --- a/lib/trivial.mal +++ b/lib/trivial.mal @@ -1,5 +1,8 @@ ;; Trivial but convenient functions. +;; Integer predecessor (number -> number) +(def! inc (fn* [a] (+ a 1))) + ;; Integer predecessor (number -> number) (def! dec (fn* (a) (- a 1))) @@ -9,4 +12,11 @@ ;; Returns the unchanged argument. (def! identity (fn* (x) x)) +;; Generate a hopefully unique symbol. +;; http://www.gigamonkeys.com/book/macros-defining-your-own.html#plugging-the-leaks +(def! gensym + (let* [counter (atom 0)] + (fn* [] + (symbol (str "G__" (swap! counter inc)))))) + nil diff --git a/livescript/step8_macros.ls b/livescript/step8_macros.ls index f6da156c..b5ac5706 100644 --- a/livescript/step8_macros.ls +++ b/livescript/step8_macros.ls @@ -321,17 +321,6 @@ rep ' (throw "odd number of forms to cond")) (cons \'cond (rest (rest xs)))))))' -# Define or. -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))))))))' - # Parse program arguments. # The first two (exe and core-file) are, respectively, # the interpreter executable (nodejs or lsc) and the diff --git a/livescript/step9_try.ls b/livescript/step9_try.ls index a77686ca..abd3b8ec 100644 --- a/livescript/step9_try.ls +++ b/livescript/step9_try.ls @@ -352,17 +352,6 @@ rep ' (throw "odd number of forms to cond")) (cons \'cond (rest (rest xs)))))))' -# Define or. -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))))))))' - # Parse program arguments. # The first two (exe and core-file) are, respectively, # the interpreter executable (nodejs or lsc) and the diff --git a/livescript/stepA_mal.ls b/livescript/stepA_mal.ls index e6c9561a..08fbd81e 100644 --- a/livescript/stepA_mal.ls +++ b/livescript/stepA_mal.ls @@ -352,25 +352,6 @@ rep ' (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)))))))))' - # Parse program arguments. # The first two (exe and core-file) are, respectively, # the interpreter executable (nodejs or lsc) and the diff --git a/logo/step8_macros.lg b/logo/step8_macros.lg index 885eff3f..d45eb827 100644 --- a/logo/step8_macros.lg +++ b/logo/step8_macros.lg @@ -201,7 +201,6 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ignore re "|(def! not (fn* (a) (if a false true)))| ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| ignore 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)))))))| -ignore 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 not emptyp :command.line [ catch "error [ignore re (word "\(load-file :space_char "\" first :command.line "\"\) )] diff --git a/logo/step9_try.lg b/logo/step9_try.lg index b5e0e7c4..ac02d269 100644 --- a/logo/step9_try.lg +++ b/logo/step9_try.lg @@ -220,7 +220,6 @@ ignore env_set :repl_env [symbol *ARGV*] argv_list ignore re "|(def! not (fn* (a) (if a false true)))| ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| ignore 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)))))))| -ignore 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 not emptyp :command.line [ catch "error [ignore re (word "\(load-file :space_char "\" first :command.line "\"\) )] diff --git a/logo/stepA_mal.lg b/logo/stepA_mal.lg index 6daba153..6c842fbe 100644 --- a/logo/stepA_mal.lg +++ b/logo/stepA_mal.lg @@ -221,9 +221,6 @@ ignore re "|(def! *host-language* "logo")| ignore re "|(def! not (fn* (a) (if a false true)))| ignore re "|(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))| ignore 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)))))))| -ignore re "|(def! inc (fn* [x] (+ x 1)))| -ignore re "|(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))| -ignore 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 not emptyp :command.line [ catch "error [ignore re (word "\(load-file :space_char "\" first :command.line "\"\) )] diff --git a/lua/step8_macros.lua b/lua/step8_macros.lua index 33538154..cb49946b 100755 --- a/lua/step8_macros.lua +++ b/lua/step8_macros.lua @@ -155,7 +155,6 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) 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 #arg > 0 and arg[1] == "--raw" then readline.raw = true diff --git a/lua/step9_try.lua b/lua/step9_try.lua index 2cb58171..b9620bfb 100755 --- a/lua/step9_try.lua +++ b/lua/step9_try.lua @@ -173,7 +173,6 @@ repl_env:set(types.Symbol:new('*ARGV*'), types.List:new(types.slice(arg,2))) 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))))))))") function print_exception(exc) if exc then diff --git a/lua/stepA_mal.lua b/lua/stepA_mal.lua index dd9ab81d..47c35ca8 100755 --- a/lua/stepA_mal.lua +++ b/lua/stepA_mal.lua @@ -175,9 +175,6 @@ rep("(def! *host-language* \"lua\")") 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)))))))))") function print_exception(exc) if exc then diff --git a/make/step8_macros.mk b/make/step8_macros.mk index 7ee0a944..310d6fda 100644 --- a/make/step8_macros.mk +++ b/make/step8_macros.mk @@ -156,7 +156,6 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) $(call do,$(call REP, (def! not (fn* (a) (if a false true))) )) $(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) )) $(call do,$(call 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))))))) )) -$(call do,$(call 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 and eval any files specified on the command line $(if $(MAKECMDGOALS),\ diff --git a/make/step9_try.mk b/make/step9_try.mk index 20667956..46a292dc 100644 --- a/make/step9_try.mk +++ b/make/step9_try.mk @@ -171,7 +171,6 @@ REPL_ENV := $(call ENV_SET,$(REPL_ENV),*ARGV*,$(_argv)) $(call do,$(call REP, (def! not (fn* (a) (if a false true))) )) $(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) )) $(call do,$(call 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))))))) )) -$(call do,$(call 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 and eval any files specified on the command line $(if $(MAKECMDGOALS),\ diff --git a/make/stepA_mal.mk b/make/stepA_mal.mk index 9c013e10..22840993 100644 --- a/make/stepA_mal.mk +++ b/make/stepA_mal.mk @@ -176,9 +176,6 @@ $(call do,$(call REP, (def! *host-language* "make") )) $(call do,$(call REP, (def! not (fn* (a) (if a false true))) )) $(call do,$(call REP, (def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")"))))) )) $(call do,$(call 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))))))) )) -$(call do,$(call REP, (def! inc (fn* [x] (+ x 1))) )) -$(call do,$(call REP, (def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc)))))) )) -$(call do,$(call 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 and eval any files specified on the command line $(if $(MAKECMDGOALS),\ diff --git a/mal/step8_macros.mal b/mal/step8_macros.mal index 872d1824..c909943b 100644 --- a/mal/step8_macros.mal +++ b/mal/step8_macros.mal @@ -127,7 +127,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 (def! repl-loop (fn* [line] diff --git a/mal/step9_try.mal b/mal/step9_try.mal index 8d939a86..a907adcd 100644 --- a/mal/step9_try.mal +++ b/mal/step9_try.mal @@ -136,7 +136,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 (def! repl-loop (fn* [line] diff --git a/mal/stepA_mal.mal b/mal/stepA_mal.mal index a4b7663b..7f498cba 100644 --- a/mal/stepA_mal.mal +++ b/mal/stepA_mal.mal @@ -137,9 +137,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 (def! repl-loop (fn* [line] diff --git a/matlab/step8_macros.m b/matlab/step8_macros.m index 7e0b46ab..db638262 100644 --- a/matlab/step8_macros.m +++ b/matlab/step8_macros.m @@ -184,7 +184,6 @@ function main(args) 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 ~isempty(args) rep(sprintf('(load-file "%s")', args{1}), repl_env); diff --git a/matlab/step9_try.m b/matlab/step9_try.m index da6447a7..a24d2a5d 100644 --- a/matlab/step9_try.m +++ b/matlab/step9_try.m @@ -208,7 +208,6 @@ function main(args) 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 ~isempty(args) rep(sprintf('(load-file "%s")', args{1}), repl_env); diff --git a/matlab/stepA_mal.m b/matlab/stepA_mal.m index 67e6bf56..a882cfad 100644 --- a/matlab/stepA_mal.m +++ b/matlab/stepA_mal.m @@ -209,9 +209,6 @@ function main(args) 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 ~isempty(args) rep(sprintf('(load-file "%s")', args{1}), repl_env); diff --git a/miniMAL/step8_macros.json b/miniMAL/step8_macros.json index b0b894d6..418806d1 100644 --- a/miniMAL/step8_macros.json +++ b/miniMAL/step8_macros.json @@ -152,7 +152,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))))))))"]], ["if", ["not", ["empty?", "ARGS"]], ["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]], diff --git a/miniMAL/step9_try.json b/miniMAL/step9_try.json index 8b05eb8d..c57a1868 100644 --- a/miniMAL/step9_try.json +++ b/miniMAL/step9_try.json @@ -165,7 +165,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))))))))"]], ["if", ["not", ["empty?", "ARGS"]], ["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]], diff --git a/miniMAL/stepA_mal.json b/miniMAL/stepA_mal.json index 401fa1ef..f7028535 100644 --- a/miniMAL/stepA_mal.json +++ b/miniMAL/stepA_mal.json @@ -166,9 +166,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)))))))))"]], ["if", ["not", ["empty?", "ARGS"]], ["rep", ["str", ["`", "(load-file \""], ["get", "ARGS", 0], ["`", "\")"]]], diff --git a/nasm/step8_macros.asm b/nasm/step8_macros.asm index 04723181..06bc9167 100644 --- a/nasm/step8_macros.asm +++ b/nasm/step8_macros.asm @@ -74,7 +74,6 @@ section .data (def! not (fn* (a) (if a false true))) \ (def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (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)))))))) \ )" ;; Command to run, appending the name of the script to run diff --git a/nasm/step9_try.asm b/nasm/step9_try.asm index 8f2ffbcc..a92b03e5 100644 --- a/nasm/step9_try.asm +++ b/nasm/step9_try.asm @@ -80,7 +80,6 @@ section .data (def! not (fn* (a) (if a false true))) \ (def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (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)))))))) \ )" ;; Command to run, appending the name of the script to run diff --git a/nasm/stepA_mal.asm b/nasm/stepA_mal.asm index a574177a..4cdf8236 100644 --- a/nasm/stepA_mal.asm +++ b/nasm/stepA_mal.asm @@ -80,9 +80,6 @@ section .data (def! not (fn* (a) (if a false true))) \ (def! load-file (fn* (f) (eval (read-string (str ",34,"(do",34," (slurp f) ",34,")",34," ))))) \ (defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw ",34,"odd number of forms to cond",34,")) (cons 'cond (rest (rest xs))))))) \ -(def! inc (fn* [x] (+ x 1))) \ -(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str ",34,"G__",34," (swap! counter inc)))))) \ -(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! *host-language* ",34,"nasm",34,")\ (def! conj nil)\ )" diff --git a/nim/step8_macros.nim b/nim/step8_macros.nim index 6de153b2..0e22bd70 100644 --- a/nim/step8_macros.nim +++ b/nim/step8_macros.nim @@ -155,7 +155,6 @@ proc rep(str: string): string {.discardable.} = 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 paramCount() >= 1: rep "(load-file \"" & paramStr(1) & "\")" diff --git a/nim/step9_try.nim b/nim/step9_try.nim index 314a42c9..f32d8d51 100644 --- a/nim/step9_try.nim +++ b/nim/step9_try.nim @@ -174,7 +174,6 @@ proc rep(str: string): string {.discardable.} = 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 paramCount() >= 1: rep "(load-file \"" & paramStr(1) & "\")" diff --git a/nim/stepA_mal.nim b/nim/stepA_mal.nim index 92e84a8e..bf47e2ee 100644 --- a/nim/stepA_mal.nim +++ b/nim/stepA_mal.nim @@ -174,9 +174,6 @@ proc rep(str: string): string {.discardable.} = 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)))))))))" rep "(def! *host-language* \"nim\")" if paramCount() >= 1: diff --git a/objc/step8_macros.m b/objc/step8_macros.m index 5c3f69e9..00e138c6 100644 --- a/objc/step8_macros.m +++ b/objc/step8_macros.m @@ -206,7 +206,6 @@ int 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 count] > 1) { diff --git a/objc/step9_try.m b/objc/step9_try.m index 23fe89f0..5b4d278c 100644 --- a/objc/step9_try.m +++ b/objc/step9_try.m @@ -225,7 +225,6 @@ int 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 count] > 1) { diff --git a/objc/stepA_mal.m b/objc/stepA_mal.m index 6b688104..fe21e1ca 100644 --- a/objc/stepA_mal.m +++ b/objc/stepA_mal.m @@ -226,9 +226,6 @@ int 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 count] > 1) { diff --git a/objpascal/step8_macros.pas b/objpascal/step8_macros.pas index a0d9dba6..e814663e 100644 --- a/objpascal/step8_macros.pas +++ b/objpascal/step8_macros.pas @@ -291,7 +291,6 @@ begin 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 ParamCount >= 1 then diff --git a/objpascal/step9_try.pas b/objpascal/step9_try.pas index d8c5960f..c93dbef4 100644 --- a/objpascal/step9_try.pas +++ b/objpascal/step9_try.pas @@ -313,7 +313,6 @@ begin 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 ParamCount >= 1 then diff --git a/objpascal/stepA_mal.pas b/objpascal/stepA_mal.pas index f77d0def..f71b8fa7 100644 --- a/objpascal/stepA_mal.pas +++ b/objpascal/stepA_mal.pas @@ -315,9 +315,6 @@ begin 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 ParamCount >= 1 then diff --git a/ocaml/step8_macros.ml b/ocaml/step8_macros.ml index 92ee6308..8b24abff 100644 --- a/ocaml/step8_macros.ml +++ b/ocaml/step8_macros.ml @@ -122,7 +122,6 @@ let rec main = ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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); - ignore (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 Array.length Sys.argv > 1 then ignore (rep ("(load-file \"" ^ Sys.argv.(1) ^ "\")") repl_env) diff --git a/ocaml/step9_try.ml b/ocaml/step9_try.ml index daea9d8e..7557d82a 100644 --- a/ocaml/step9_try.ml +++ b/ocaml/step9_try.ml @@ -136,7 +136,6 @@ let rec main = ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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); - ignore (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 Array.length Sys.argv > 1 then try diff --git a/ocaml/stepA_mal.ml b/ocaml/stepA_mal.ml index e1e42b29..41624214 100644 --- a/ocaml/stepA_mal.ml +++ b/ocaml/stepA_mal.ml @@ -137,9 +137,6 @@ let rec main = ignore (rep "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" repl_env); ignore (rep "(def! not (fn* (a) (if a false true)))" repl_env); ignore (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); - ignore (rep "(def! inc (fn* [x] (+ x 1)))" repl_env); - ignore (rep "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))" repl_env); - ignore (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 Array.length Sys.argv > 1 then try diff --git a/perl/step8_macros.pl b/perl/step8_macros.pl index 62b4723c..3c8826ca 100644 --- a/perl/step8_macros.pl +++ b/perl/step8_macros.pl @@ -198,7 +198,6 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_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 (scalar(@ARGV) > 0 && $ARGV[0] eq "--raw") { diff --git a/perl/step9_try.pl b/perl/step9_try.pl index 17ce2d4d..2eee0470 100644 --- a/perl/step9_try.pl +++ b/perl/step9_try.pl @@ -226,7 +226,6 @@ $repl_env->set(Symbol->new('*ARGV*'), List->new(\@_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 (scalar(@ARGV) > 0 && $ARGV[0] eq "--raw") { diff --git a/perl/stepA_mal.pl b/perl/stepA_mal.pl index 991c988b..2071c656 100644 --- a/perl/stepA_mal.pl +++ b/perl/stepA_mal.pl @@ -230,10 +230,6 @@ REP("(def! *host-language* \"perl\")"); 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 (scalar(@ARGV) > 0 && $ARGV[0] eq "--raw") { set_rl_mode("raw"); diff --git a/perl6/step8_macros.pl b/perl6/step8_macros.pl index 39491593..375388c8 100644 --- a/perl6/step8_macros.pl +++ b/perl6/step8_macros.pl @@ -127,7 +127,6 @@ sub MAIN ($source_file?, *@args) { rep(q{(def! not (fn* (a) (if a false true)))}); rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); rep(q{(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(q{(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 ($source_file.defined) { rep("(load-file \"$source_file\")"); diff --git a/perl6/step9_try.pl b/perl6/step9_try.pl index 23615889..6ce28129 100644 --- a/perl6/step9_try.pl +++ b/perl6/step9_try.pl @@ -137,7 +137,6 @@ sub MAIN ($source_file?, *@args) { rep(q{(def! not (fn* (a) (if a false true)))}); rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); rep(q{(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(q{(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 ($source_file.defined) { rep("(load-file \"$source_file\")"); diff --git a/perl6/stepA_mal.pl b/perl6/stepA_mal.pl index 2f558232..c70a96a6 100644 --- a/perl6/stepA_mal.pl +++ b/perl6/stepA_mal.pl @@ -138,9 +138,6 @@ sub MAIN ($source_file?, *@args) { rep(q{(def! not (fn* (a) (if a false true)))}); rep(q{(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))}); rep(q{(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(q{(def! inc (fn* [x] (+ x 1)))}); - rep(q{(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))}); - rep(q{(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 ($source_file.defined) { rep("(load-file \"$source_file\")"); diff --git a/php/step8_macros.php b/php/step8_macros.php index 0537d61b..81ab58b4 100644 --- a/php/step8_macros.php +++ b/php/step8_macros.php @@ -174,7 +174,6 @@ $repl_env->set(_symbol('*ARGV*'), $_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 (count($argv) > 1) { rep('(load-file "' . $argv[1] . '")'); diff --git a/php/step9_try.php b/php/step9_try.php index 7f87f1b7..323ec3ce 100644 --- a/php/step9_try.php +++ b/php/step9_try.php @@ -192,7 +192,6 @@ $repl_env->set(_symbol('*ARGV*'), $_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 (count($argv) > 1) { rep('(load-file "' . $argv[1] . '")'); diff --git a/php/stepA_mal.php b/php/stepA_mal.php index c0cb0d48..dc89ab7d 100644 --- a/php/stepA_mal.php +++ b/php/stepA_mal.php @@ -201,9 +201,6 @@ rep("(def! *host-language* \"php\")"); 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)))))))))"); // run mal file if (count($argv) > 1) { diff --git a/picolisp/step8_macros.l b/picolisp/step8_macros.l index 8bef4bb0..b1445d86 100644 --- a/picolisp/step8_macros.l +++ b/picolisp/step8_macros.l @@ -131,7 +131,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))))))))") + (load-history ".mal_history") diff --git a/picolisp/step9_try.l b/picolisp/step9_try.l index c5e42d43..74fe8c27 100644 --- a/picolisp/step9_try.l +++ b/picolisp/step9_try.l @@ -144,7 +144,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))))))))") (load-history ".mal_history") diff --git a/picolisp/stepA_mal.l b/picolisp/stepA_mal.l index 629562fd..94b5fd2f 100644 --- a/picolisp/stepA_mal.l +++ b/picolisp/stepA_mal.l @@ -146,10 +146,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! 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-history ".mal_history") (if (argv) diff --git a/plpgsql/step8_macros.sql b/plpgsql/step8_macros.sql index c89acfdf..fe935af7 100644 --- a/plpgsql/step8_macros.sql +++ b/plpgsql/step8_macros.sql @@ -295,7 +295,6 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' SELECT 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)))))))') \g '/dev/null' -SELECT 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))))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) RETURNS integer AS $$ diff --git a/plpgsql/step9_try.sql b/plpgsql/step9_try.sql index 291cdaac..d3623bd2 100644 --- a/plpgsql/step9_try.sql +++ b/plpgsql/step9_try.sql @@ -314,7 +314,6 @@ SELECT envs.vset(0, '*ARGV*', mal.READ('()')) \g '/dev/null' SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' SELECT 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)))))))') \g '/dev/null' -SELECT 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))))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) RETURNS integer AS $$ diff --git a/plpgsql/stepA_mal.sql b/plpgsql/stepA_mal.sql index 448d812e..eb44d4f4 100644 --- a/plpgsql/stepA_mal.sql +++ b/plpgsql/stepA_mal.sql @@ -315,9 +315,6 @@ SELECT mal.REP('(def! *host-language* "plpqsql")') \g '/dev/null' SELECT mal.REP('(def! not (fn* (a) (if a false true)))') \g '/dev/null' SELECT mal.REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') \g '/dev/null' SELECT 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)))))))') \g '/dev/null' -SELECT mal.REP('(def! inc (fn* [x] (+ x 1)))') \g '/dev/null' -SELECT mal.REP('(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))') \g '/dev/null' -SELECT 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)))))))))') \g '/dev/null' CREATE FUNCTION mal.MAIN(pwd varchar, argstring varchar DEFAULT NULL) RETURNS integer AS $$ diff --git a/plsql/step8_macros.sql b/plsql/step8_macros.sql index c05b10a9..cee72aab 100644 --- a/plsql/step8_macros.sql +++ b/plsql/step8_macros.sql @@ -325,7 +325,6 @@ BEGIN line := REP('(def! not (fn* (a) (if a false true)))'); line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); line := 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)))))))'); - line := 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 argv.COUNT() > 0 THEN BEGIN diff --git a/plsql/step9_try.sql b/plsql/step9_try.sql index d69eee37..2e2bb521 100644 --- a/plsql/step9_try.sql +++ b/plsql/step9_try.sql @@ -411,7 +411,6 @@ BEGIN line := REP('(def! not (fn* (a) (if a false true)))'); line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); line := 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)))))))'); - line := 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 argv.COUNT() > 0 THEN BEGIN diff --git a/plsql/stepA_mal.sql b/plsql/stepA_mal.sql index 6c5f6c9e..9df1750d 100644 --- a/plsql/stepA_mal.sql +++ b/plsql/stepA_mal.sql @@ -412,9 +412,6 @@ BEGIN line := REP('(def! not (fn* (a) (if a false true)))'); line := REP('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))'); line := 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)))))))'); - line := REP('(def! inc (fn* [x] (+ x 1)))'); - line := REP('(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))'); - line := 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 argv.COUNT() > 0 THEN BEGIN diff --git a/powershell/step8_macros.ps1 b/powershell/step8_macros.ps1 index 295c91bd..243131f3 100644 --- a/powershell/step8_macros.ps1 +++ b/powershell/step8_macros.ps1 @@ -171,7 +171,6 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) $_ = 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 ($args.Count -gt 0) { diff --git a/powershell/step9_try.ps1 b/powershell/step9_try.ps1 index e913d14f..e2f8f07f 100644 --- a/powershell/step9_try.ps1 +++ b/powershell/step9_try.ps1 @@ -187,7 +187,6 @@ $_ = $repl_env.set((new-symbol "*ARGV*"), (new-list $args[1..$args.Count])) $_ = 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 ($args.Count -gt 0) { diff --git a/powershell/stepA_mal.ps1 b/powershell/stepA_mal.ps1 index 1e616e79..be46d061 100644 --- a/powershell/stepA_mal.ps1 +++ b/powershell/stepA_mal.ps1 @@ -188,9 +188,6 @@ $_ = REP('(def! *host-language* "powershell")') $_ = 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 ($args.Count -gt 0) { diff --git a/process/guide.md b/process/guide.md index 0e9c571b..4c0f4393 100644 --- a/process/guide.md +++ b/process/guide.md @@ -1331,15 +1331,15 @@ implementation. Let us continue! * `rest`: this function takes a list (or vector) as its argument and returns a new list containing all the elements except the first. -* In the main program, use the `rep` function to define two new - control structures macros. Here are the string arguments for `rep` - to define these macros: - * `cond`: "(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)))))))" +* In the main program, call the `rep` function with the following + string argument to define a new control structure. +``` +"(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)))))))" +``` * Note that `cond` calls the `throw` function when `cond` is called with an odd number of args. The `throw` function is implemented in the next step, but it will still serve it's purpose here by causing an undefined symbol error. - * `or`: "(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))))))))" @@ -1608,33 +1608,6 @@ implementation to run a mal implementation which itself runs the mal implementation. -#### Optional: gensym - -The `or` macro we introduced at step 8 has a bug. It defines a -variable called `or_FIXME`, which "shadows" such a binding from the -user's code (which uses the macro). If a user has a variable called -`or_FIXME`, it cannot be used as an `or` macro argument. In order to -fix that, we'll introduce `gensym`: a function which returns a symbol -which was never used before anywhere in the program. This is also an -example for the use of mal atoms to keep state (the state here being -the number of symbols produced by `gensym` so far). - -Previously you used `rep` to define the `or` macro. Remove that -definition and use `rep` to define the new counter, `gensym` function -and the clean `or` macro. Here are the string arguments you need to -pass to `rep`: -``` -"(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)))))))))" -``` - -For extra information read [Peter Seibel's thorough discussion about -`gensym` and leaking macros in Common Lisp](http://www.gigamonkeys.com/book/macros-defining-your-own.html#plugging-the-leaks). - - #### Optional additions * Add metadata support to other composite data types (lists, vectors diff --git a/process/step8_macros.txt b/process/step8_macros.txt index b84b73a3..93da781a 100644 --- a/process/step8_macros.txt +++ b/process/step8_macros.txt @@ -52,7 +52,6 @@ repl_env.set('*ARGV*, cmdline_args[1..]) 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/step9_try.txt b/process/step9_try.txt index 0c070e8d..26418054 100644 --- a/process/step9_try.txt +++ b/process/step9_try.txt @@ -53,7 +53,6 @@ repl_env.set('*ARGV*, cmdline_args[1..]) 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/process/stepA_mal.txt b/process/stepA_mal.txt index bbb8b405..b88a5afa 100644 --- a/process/stepA_mal.txt +++ b/process/stepA_mal.txt @@ -54,9 +54,6 @@ rep("(def! *host-language* \"racket\")") 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 cmdline_args: rep("(load-file \"" + args[0] + "\")"); exit 0 diff --git a/ps/step8_macros.ps b/ps/step8_macros.ps index 51eabc98..925b1796 100644 --- a/ps/step8_macros.ps +++ b/ps/step8_macros.ps @@ -213,7 +213,6 @@ core_ns { _function _ref } forall (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop (\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop (\(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 pop -(\(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\)\)\)\)\)\)\)\)) RE pop userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments diff --git a/ps/step9_try.ps b/ps/step9_try.ps index 207b6f65..c25168f1 100644 --- a/ps/step9_try.ps +++ b/ps/step9_try.ps @@ -253,7 +253,6 @@ core_ns { _function _ref } forall (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop (\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop (\(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 pop -(\(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\)\)\)\)\)\)\)\)) RE pop userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments diff --git a/ps/stepA_mal.ps b/ps/stepA_mal.ps index 7cecd70b..f6032980 100644 --- a/ps/stepA_mal.ps +++ b/ps/stepA_mal.ps @@ -263,9 +263,6 @@ core_ns { _function _ref } forall (\(def! not \(fn* \(a\) \(if a false true\)\)\)) RE pop (\(def! load-file \(fn* \(f\) \(eval \(read-string \(str "\(do " \(slurp f\) "\)"\)\)\)\)\)) RE pop (\(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 pop -(\(def! inc \(fn* [x] \(+ x 1\)\)\)) RE pop -(\(def! gensym \(let* [counter \(atom 0\)] \(fn* [] \(symbol \(str "G__" \(swap! counter inc\)\)\)\)\)\)) RE pop -(\(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\)\)\)\)\)\)\)\)\)) RE pop userdict /ARGUMENTS known { %if command line arguments ARGUMENTS length 0 gt { %if more than 0 arguments diff --git a/python/step8_macros.py b/python/step8_macros.py index cdf79693..9c8d392a 100644 --- a/python/step8_macros.py +++ b/python/step8_macros.py @@ -135,7 +135,6 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) 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 len(sys.argv) >= 2: REP('(load-file "' + sys.argv[1] + '")') diff --git a/python/step9_try.py b/python/step9_try.py index a6fb4290..b1b591bc 100644 --- a/python/step9_try.py +++ b/python/step9_try.py @@ -157,7 +157,6 @@ repl_env.set(types._symbol('*ARGV*'), types._list(*sys.argv[2:])) 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 len(sys.argv) >= 2: REP('(load-file "' + sys.argv[1] + '")') diff --git a/python/stepA_mal.py b/python/stepA_mal.py index 0cada9c4..c9bae23e 100644 --- a/python/stepA_mal.py +++ b/python/stepA_mal.py @@ -161,9 +161,6 @@ REP("(def! *host-language* \"python\")") 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 len(sys.argv) >= 2: REP('(load-file "' + sys.argv[1] + '")') diff --git a/r/step8_macros.r b/r/step8_macros.r index d8d3ba19..33d251f7 100644 --- a/r/step8_macros.r +++ b/r/step8_macros.r @@ -154,7 +154,6 @@ Env.set(repl_env, "*ARGV*", new.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))))))))") args <- commandArgs(trailingOnly = TRUE) diff --git a/r/step9_try.r b/r/step9_try.r index 049d6605..f3c5d421 100644 --- a/r/step9_try.r +++ b/r/step9_try.r @@ -168,7 +168,6 @@ Env.set(repl_env, "*ARGV*", new.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))))))))") args <- commandArgs(trailingOnly = TRUE) diff --git a/r/stepA_mal.r b/r/stepA_mal.r index b448ff98..2d610526 100644 --- a/r/stepA_mal.r +++ b/r/stepA_mal.r @@ -169,9 +169,6 @@ Env.set(repl_env, "*ARGV*", new.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("(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)))))))))") args <- commandArgs(trailingOnly = TRUE) diff --git a/racket/step8_macros.rkt b/racket/step8_macros.rkt index ca281057..ebcb71e8 100755 --- a/racket/step8_macros.rkt +++ b/racket/step8_macros.rkt @@ -126,7 +126,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))))))))") ) diff --git a/racket/step9_try.rkt b/racket/step9_try.rkt index 79f21b63..06ec7581 100755 --- a/racket/step9_try.rkt +++ b/racket/step9_try.rkt @@ -142,7 +142,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))))))))") ) diff --git a/racket/stepA_mal.rkt b/racket/stepA_mal.rkt index aea36db7..dfdfb3ad 100755 --- a/racket/stepA_mal.rkt +++ b/racket/stepA_mal.rkt @@ -143,9 +143,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)))))))))") ) diff --git a/rexx/step8_macros.rexx b/rexx/step8_macros.rexx index 7430a0b0..60482a09 100644 --- a/rexx/step8_macros.rexx +++ b/rexx/step8_macros.rexx @@ -245,7 +245,6 @@ main: x = re("(def! not (fn* (a) (if a false true)))") x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') x = 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)))))))"); - x = 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))))))))"); err = "" if command_line_args.0 > 0 then do diff --git a/rexx/step9_try.rexx b/rexx/step9_try.rexx index 86a6d6e9..d201b37a 100644 --- a/rexx/step9_try.rexx +++ b/rexx/step9_try.rexx @@ -261,7 +261,6 @@ main: x = re("(def! not (fn* (a) (if a false true)))") x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') x = 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)))))))"); - x = 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))))))))"); err = "" if command_line_args.0 > 0 then do diff --git a/rexx/stepA_mal.rexx b/rexx/stepA_mal.rexx index 04c2da19..3c127a3f 100644 --- a/rexx/stepA_mal.rexx +++ b/rexx/stepA_mal.rexx @@ -263,9 +263,6 @@ main: x = re("(def! not (fn* (a) (if a false true)))") x = re('(def! load-file (fn* (f) (eval (read-string (str "(do " (slurp f) ")")))))') x = 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)))))))"); - x = re("(def! inc (fn* [x] (+ x 1)))") - x = re('(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str "G__" (swap! counter inc))))))') - x = 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)))))))))") err = "" if command_line_args.0 > 0 then do diff --git a/rpython/step8_macros.py b/rpython/step8_macros.py index c231b10d..811cd14b 100644 --- a/rpython/step8_macros.py +++ b/rpython/step8_macros.py @@ -168,7 +168,6 @@ def entry_point(argv): 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 len(argv) >= 2: REP('(load-file "' + argv[1] + '")', repl_env) diff --git a/rpython/step9_try.py b/rpython/step9_try.py index 16a40622..9c58d7b2 100644 --- a/rpython/step9_try.py +++ b/rpython/step9_try.py @@ -186,7 +186,6 @@ def entry_point(argv): 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 len(argv) >= 2: REP('(load-file "' + argv[1] + '")', repl_env) diff --git a/rpython/stepA_mal.py b/rpython/stepA_mal.py index 5fd5592b..6c73a48c 100644 --- a/rpython/stepA_mal.py +++ b/rpython/stepA_mal.py @@ -196,9 +196,6 @@ def entry_point(argv): 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 len(argv) >= 2: REP('(load-file "' + argv[1] + '")', repl_env) diff --git a/ruby/step8_macros.rb b/ruby/step8_macros.rb index e29e1e09..46a64e53 100644 --- a/ruby/step8_macros.rb +++ b/ruby/step8_macros.rb @@ -147,7 +147,6 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) 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 ARGV.size > 0 RE["(load-file \"" + ARGV[0] + "\")"] diff --git a/ruby/step9_try.rb b/ruby/step9_try.rb index 3a004912..96fc5ee2 100644 --- a/ruby/step9_try.rb +++ b/ruby/step9_try.rb @@ -162,7 +162,6 @@ repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || [])) 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 ARGV.size > 0 RE["(load-file \"" + ARGV[0] + "\")"] diff --git a/ruby/stepA_mal.rb b/ruby/stepA_mal.rb index 756811a6..14f7f785 100644 --- a/ruby/stepA_mal.rb +++ b/ruby/stepA_mal.rb @@ -169,9 +169,6 @@ RE["(def! *host-language* \"ruby\")"] 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 ARGV.size > 0 RE["(load-file \"" + ARGV[0] + "\")"] diff --git a/rust/step8_macros.rs b/rust/step8_macros.rs index 2c3bd341..02cb6de1 100644 --- a/rust/step8_macros.rs +++ b/rust/step8_macros.rs @@ -303,7 +303,6 @@ fn main() { let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); let _ = 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); - let _ = 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); // Invoked with arguments diff --git a/rust/step9_try.rs b/rust/step9_try.rs index 3c7874ff..1d91d762 100644 --- a/rust/step9_try.rs +++ b/rust/step9_try.rs @@ -324,7 +324,6 @@ fn main() { let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); let _ = 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); - let _ = 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); // Invoked with arguments diff --git a/rust/stepA_mal.rs b/rust/stepA_mal.rs index b65359ae..2692fdde 100644 --- a/rust/stepA_mal.rs +++ b/rust/stepA_mal.rs @@ -327,9 +327,6 @@ fn main() { let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env); let _ = rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", &repl_env); let _ = 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); - let _ = rep("(def! inc (fn* [x] (+ x 1)))", &repl_env); - let _ = rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", &repl_env); - let _ = 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); // Invoked with arguments diff --git a/scala/step8_macros.scala b/scala/step8_macros.scala index 48d15c25..06206125 100644 --- a/scala/step8_macros.scala +++ b/scala/step8_macros.scala @@ -186,7 +186,6 @@ object 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 (args.length > 0) { diff --git a/scala/step9_try.scala b/scala/step9_try.scala index cc997bbe..fe6df011 100644 --- a/scala/step9_try.scala +++ b/scala/step9_try.scala @@ -207,7 +207,6 @@ object 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 (args.length > 0) { diff --git a/scala/stepA_mal.scala b/scala/stepA_mal.scala index 722620a5..bbdbd098 100644 --- a/scala/stepA_mal.scala +++ b/scala/stepA_mal.scala @@ -208,9 +208,6 @@ object 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 (args.length > 0) { diff --git a/scheme/step8_macros.scm b/scheme/step8_macros.scm index c9f177e3..07bc86c7 100644 --- a/scheme/step8_macros.scm +++ b/scheme/step8_macros.scm @@ -171,9 +171,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))))))))") (define (main) diff --git a/scheme/step9_try.scm b/scheme/step9_try.scm index b28e786c..a8d99cde 100644 --- a/scheme/step9_try.scm +++ b/scheme/step9_try.scm @@ -189,9 +189,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))))))))") (define (main) diff --git a/scheme/stepA_mal.scm b/scheme/stepA_mal.scm index 408eed3e..af1f1045 100644 --- a/scheme/stepA_mal.scm +++ b/scheme/stepA_mal.scm @@ -191,11 +191,6 @@ (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)))))))") (define (main) diff --git a/skew/step8_macros.sk b/skew/step8_macros.sk index 44565979..3c6307b7 100644 --- a/skew/step8_macros.sk +++ b/skew/step8_macros.sk @@ -153,7 +153,6 @@ def main { 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 argv.count > 0 { RE("(load-file \"" + argv[0] + "\")") diff --git a/skew/step9_try.sk b/skew/step9_try.sk index e9516315..bb93792a 100644 --- a/skew/step9_try.sk +++ b/skew/step9_try.sk @@ -167,7 +167,6 @@ def main { 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 argv.count > 0 { RE("(load-file \"" + argv[0] + "\")") diff --git a/skew/stepA_mal.sk b/skew/stepA_mal.sk index 798aa156..983c3e10 100644 --- a/skew/stepA_mal.sk +++ b/skew/stepA_mal.sk @@ -168,9 +168,6 @@ def main { 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 argv.count > 0 { RE("(load-file \"" + argv[0] + "\")") diff --git a/swift/step8_macros.swift b/swift/step8_macros.swift index e0391ced..eb99f0fb 100644 --- a/swift/step8_macros.swift +++ b/swift/step8_macros.swift @@ -583,8 +583,6 @@ func main() { RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", 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)))))))", 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))))))))", env) env.set(kSymbolEval, make_builtin({ try! unwrap_args($0) { diff --git a/swift/step9_try.swift b/swift/step9_try.swift index b0b8b314..40973200 100644 --- a/swift/step9_try.swift +++ b/swift/step9_try.swift @@ -616,8 +616,6 @@ func main() { RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", 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)))))))", 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))))))))", env) env.set(kSymbolEval, make_builtin({ try! unwrap_args($0) { diff --git a/swift/stepA_mal.swift b/swift/stepA_mal.swift index d1b0adf0..cbdaa79a 100644 --- a/swift/stepA_mal.swift +++ b/swift/stepA_mal.swift @@ -617,10 +617,6 @@ func main() { RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", 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)))))))", env) - RE("(def! inc (fn* [x] (+ x 1)))", env) - RE("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", 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)))))))))", env) env.set(kSymbolEval, make_builtin({ try! unwrap_args($0) { diff --git a/swift3/Sources/step8_macros/main.swift b/swift3/Sources/step8_macros/main.swift index a53483f0..46c3cc3a 100644 --- a/swift3/Sources/step8_macros/main.swift +++ b/swift3/Sources/step8_macros/main.swift @@ -217,7 +217,6 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) try rep("(def! not (fn* (a) (if a false true)))") try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") try 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)))))))") -try 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 CommandLine.arguments.count > 1 { diff --git a/swift3/Sources/step9_try/main.swift b/swift3/Sources/step9_try/main.swift index 900dd3e3..7344bba4 100644 --- a/swift3/Sources/step9_try/main.swift +++ b/swift3/Sources/step9_try/main.swift @@ -250,7 +250,6 @@ try repl_env.set(MalVal.MalSymbol("*ARGV*"), list(Array(args))) try rep("(def! not (fn* (a) (if a false true)))") try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") try 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)))))))") -try 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 CommandLine.arguments.count > 1 { diff --git a/swift3/Sources/stepA_mal/main.swift b/swift3/Sources/stepA_mal/main.swift index b7a51532..55d81547 100644 --- a/swift3/Sources/stepA_mal/main.swift +++ b/swift3/Sources/stepA_mal/main.swift @@ -251,9 +251,6 @@ try rep("(def! *host-language* \"swift\")") try rep("(def! not (fn* (a) (if a false true)))") try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))") try 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)))))))") -try rep("(def! inc (fn* [x] (+ x 1)))") -try rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))") -try 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 CommandLine.arguments.count > 1 { diff --git a/swift4/Sources/step8_macros/main.swift b/swift4/Sources/step8_macros/main.swift index e4bc7ef9..b9d1f48a 100644 --- a/swift4/Sources/step8_macros/main.swift +++ b/swift4/Sources/step8_macros/main.swift @@ -166,7 +166,6 @@ repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) try 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: repl_env) -try 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: repl_env) if CommandLine.argc > 1 { let fileName = CommandLine.arguments[1], diff --git a/swift4/Sources/step9_try/main.swift b/swift4/Sources/step9_try/main.swift index 26624f72..c2bc8ec6 100644 --- a/swift4/Sources/step9_try/main.swift +++ b/swift4/Sources/step9_try/main.swift @@ -178,7 +178,6 @@ repl_env.set([], forKey: Symbol("*ARGV*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) try 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: repl_env) -try 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: repl_env) if CommandLine.argc > 1 { let fileName = CommandLine.arguments[1], diff --git a/swift4/Sources/stepA_mal/main.swift b/swift4/Sources/stepA_mal/main.swift index a2cc2b74..a1f9eb51 100644 --- a/swift4/Sources/stepA_mal/main.swift +++ b/swift4/Sources/stepA_mal/main.swift @@ -180,9 +180,6 @@ repl_env.set("Swift4", forKey: Symbol("*host-language*")) try rep("(def! not (fn* (a) (if a false true)))", env: repl_env) try rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env: repl_env) try 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: repl_env) -try rep("(def! inc (fn* [x] (+ x 1)))", env: repl_env) -try rep("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", env: repl_env) -try 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: repl_env) if CommandLine.argc > 1 { let fileName = CommandLine.arguments[1], diff --git a/tcl/step8_macros.tcl b/tcl/step8_macros.tcl index 7329d8b4..9ee25aa3 100644 --- a/tcl/step8_macros.tcl +++ b/tcl/step8_macros.tcl @@ -227,7 +227,6 @@ $repl_env set "*ARGV*" [list_new $argv_list] 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 fconfigure stdout -translation binary diff --git a/tcl/step9_try.tcl b/tcl/step9_try.tcl index e190f802..dd4ef788 100644 --- a/tcl/step9_try.tcl +++ b/tcl/step9_try.tcl @@ -245,7 +245,6 @@ $repl_env set "*ARGV*" [list_new $argv_list] 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 fconfigure stdout -translation binary diff --git a/tcl/stepA_mal.tcl b/tcl/stepA_mal.tcl index 62d4f8e1..71c09c7a 100644 --- a/tcl/stepA_mal.tcl +++ b/tcl/stepA_mal.tcl @@ -249,9 +249,6 @@ RE "(def! *host-language* \"tcl\")" $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 "(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 fconfigure stdout -translation binary diff --git a/tests/lib/test_cascade.mal b/tests/lib/test_cascade.mal index b6c2f3c1..6db6698e 100644 --- a/tests/lib/test_cascade.mal +++ b/tests/lib/test_cascade.mal @@ -1,6 +1,24 @@ (load-file "../lib/test_cascade.mal") ;=>nil +;; Testing or +(or) +;=>nil +(or 1) +;=>1 +(or 1 2 3 4) +;=>1 +(or false 2) +;=>2 +(or false nil 3) +;=>3 +(or false nil false false nil 4) +;=>4 +(or false nil 3 false nil 4) +;=>3 +(or (or false 4)) +;=>4 + ;; Testing every? (every? first []) ;=>true diff --git a/tests/lib/trivial.mal b/tests/lib/trivial.mal index 6f2f813f..d32ce313 100644 --- a/tests/lib/trivial.mal +++ b/tests/lib/trivial.mal @@ -1,6 +1,8 @@ (load-file "../lib/trivial.mal") ;=>nil +(inc 12) +;=>13 (dec 12) ;=>11 (zero? 12) @@ -9,3 +11,5 @@ ;=>true (identity 12) ;=>12 +(= (gensym) (gensym)) +;=>false diff --git a/tests/step8_macros.mal b/tests/step8_macros.mal index 59868928..79f332ab 100644 --- a/tests/step8_macros.mal +++ b/tests/step8_macros.mal @@ -69,24 +69,6 @@ x ;=>(8 9) -;; Testing or macro -(or) -;=>nil -(or 1) -;=>1 -(or 1 2 3 4) -;=>1 -(or false 2) -;=>2 -(or false nil 3) -;=>3 -(or false nil false false nil 4) -;=>4 -(or false nil 3 false nil 4) -;=>3 -(or (or false 4)) -;=>4 - ;; Testing cond macro (cond) @@ -106,7 +88,7 @@ x ;; Testing EVAL in let* -(let* (x (or nil "yes")) x) +(let* (x (cond false "no" true "yes")) x) ;=>"yes" @@ -146,7 +128,7 @@ x ;; Testing EVAL in vector let* -(let* [x (or nil "yes")] x) +(let* [x (cond false "no" true "yes")] x) ;=>"yes" ;>>> soft=True diff --git a/tests/step9_try.mal b/tests/step9_try.mal index 1f90e31a..9e39ba16 100644 --- a/tests/step9_try.mal +++ b/tests/step9_try.mal @@ -294,11 +294,11 @@ ;=>"true \".\" false \".\" nil \".\" :keyw \".\" symb" (def! s (str {:abc "val1" :def "val2"})) -(or (= s "{:abc val1 :def val2}") (= s "{:def val2 :abc val1}")) +(cond (= s "{:abc val1 :def val2}") true (= s "{:def val2 :abc val1}") true) ;=>true (def! p (pr-str {:abc "val1" :def "val2"})) -(or (= p "{:abc \"val1\" :def \"val2\"}") (= p "{:def \"val2\" :abc \"val1\"}")) +(cond (= p "{:abc \"val1\" :def \"val2\"}") true (= p "{:def \"val2\" :abc \"val1\"}") true) ;=>true ;; diff --git a/tests/stepA_mal.mal b/tests/stepA_mal.mal index 58ba909e..70da5ea8 100644 --- a/tests/stepA_mal.mal +++ b/tests/stepA_mal.mal @@ -274,18 +274,6 @@ (meta +) ;=>nil -;; -;; Testing inc -(inc 12) -;=>13 - -;; -;; Testing gensym and clean or macro -(= (gensym) (gensym)) -;=>false -(let* [or_FIXME 23] (or false (+ or_FIXME 100))) -;=>123 - ;; Loading sumdown from computations.mal (load-file "../tests/computations.mal") diff --git a/ts/step8_macros.ts b/ts/step8_macros.ts index 0c915662..f81fa5b8 100644 --- a/ts/step8_macros.ts +++ b/ts/step8_macros.ts @@ -276,7 +276,6 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); 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 (typeof process !== "undefined" && 2 < process.argv.length) { replEnv.set(MalSymbol.get("*ARGV*"), new MalList(process.argv.slice(3).map(s => new MalString(s)))); diff --git a/ts/step9_try.ts b/ts/step9_try.ts index eb22b39b..2074b787 100644 --- a/ts/step9_try.ts +++ b/ts/step9_try.ts @@ -301,7 +301,6 @@ replEnv.set(MalSymbol.get("*ARGV*"), new MalList([])); 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 (typeof process !== "undefined" && 2 < process.argv.length) { replEnv.set(MalSymbol.get("*ARGV*"), new MalList(process.argv.slice(3).map(s => new MalString(s)))); diff --git a/ts/stepA_mal.ts b/ts/stepA_mal.ts index 61e6a15c..c5bbf31c 100644 --- a/ts/stepA_mal.ts +++ b/ts/stepA_mal.ts @@ -302,9 +302,6 @@ rep(`(def! *host-language* "TypeScript")`); 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 (typeof process !== "undefined" && 2 < process.argv.length) { replEnv.set(MalSymbol.get("*ARGV*"), new MalList(process.argv.slice(3).map(s => new MalString(s)))); diff --git a/vala/step8_macros.vala b/vala/step8_macros.vala index 5e909d66..f6cdd365 100644 --- a/vala/step8_macros.vala +++ b/vala/step8_macros.vala @@ -337,7 +337,6 @@ class Mal.Main : GLib.Object { setup("(def! not (fn* (a) (if a false true)))", env); setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); setup("(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); - setup("(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); var ARGV = new GLib.List(); if (args.length > 1) { diff --git a/vala/step9_try.vala b/vala/step9_try.vala index 0c2fcf16..813b27d7 100644 --- a/vala/step9_try.vala +++ b/vala/step9_try.vala @@ -375,7 +375,6 @@ class Mal.Main : GLib.Object { setup("(def! not (fn* (a) (if a false true)))", env); setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); setup("(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); - setup("(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); var ARGV = new GLib.List(); if (args.length > 1) { diff --git a/vala/stepA_mal.vala b/vala/stepA_mal.vala index d1d105f4..b0ed9148 100644 --- a/vala/stepA_mal.vala +++ b/vala/stepA_mal.vala @@ -376,9 +376,6 @@ class Mal.Main : GLib.Object { setup("(def! not (fn* (a) (if a false true)))", env); setup("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", env); setup("(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); - setup("(def! inc (fn* [x] (+ x 1)))", env); - setup("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", env); - setup("(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); var ARGV = new GLib.List(); if (args.length > 1) { diff --git a/vb/step8_macros.vb b/vb/step8_macros.vb index 1e977aed..32e102d1 100644 --- a/vb/step8_macros.vb +++ b/vb/step8_macros.vb @@ -254,7 +254,6 @@ Namespace 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("(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 Then REP("(load-file """ & args(fileIdx) & """)") diff --git a/vb/step9_try.vb b/vb/step9_try.vb index 690182db..83bd1bf7 100644 --- a/vb/step9_try.vb +++ b/vb/step9_try.vb @@ -277,7 +277,6 @@ Namespace 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("(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 Then REP("(load-file """ & args(fileIdx) & """)") diff --git a/vb/stepA_mal.vb b/vb/stepA_mal.vb index cd7f632f..b10b43c2 100644 --- a/vb/stepA_mal.vb +++ b/vb/stepA_mal.vb @@ -278,9 +278,6 @@ Namespace 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 args.Length > fileIdx Then REP("(load-file """ & args(fileIdx) & """)") diff --git a/vhdl/step8_macros.vhdl b/vhdl/step8_macros.vhdl index 662b3959..028f8545 100644 --- a/vhdl/step8_macros.vhdl +++ b/vhdl/step8_macros.vhdl @@ -411,7 +411,6 @@ architecture test of step8_macros is RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); 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, dummy_val, err); - 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, dummy_val, err); if program_file /= null then REP("(load-file " & '"' & program_file.all & '"' & ")", repl_env, result, err); diff --git a/vhdl/step9_try.vhdl b/vhdl/step9_try.vhdl index 0e4b2d95..ece0ceab 100644 --- a/vhdl/step9_try.vhdl +++ b/vhdl/step9_try.vhdl @@ -469,7 +469,6 @@ architecture test of step9_try is RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); 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, dummy_val, err); - 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, dummy_val, err); if program_file /= null then REP("(load-file " & '"' & program_file.all & '"' & ")", repl_env, result, err); diff --git a/vhdl/stepA_mal.vhdl b/vhdl/stepA_mal.vhdl index 4006e416..80812c16 100644 --- a/vhdl/stepA_mal.vhdl +++ b/vhdl/stepA_mal.vhdl @@ -470,9 +470,6 @@ architecture test of stepA_mal is RE("(def! not (fn* (a) (if a false true)))", repl_env, dummy_val, err); RE("(def! load-file (fn* (f) (eval (read-string (str " & '"' & "(do " & '"' & " (slurp f) " & '"' & ")" & '"' & ")))))", repl_env, dummy_val, err); 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, dummy_val, err); - RE("(def! inc (fn* [x] (+ x 1)))", repl_env, dummy_val, err); - RE("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str " & '"' & "G__" & '"' & " (swap! counter inc))))))", repl_env, dummy_val, err); - 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, dummy_val, err); if program_file /= null then REP("(load-file " & '"' & program_file.all & '"' & ")", repl_env, result, err); diff --git a/vimscript/step8_macros.vim b/vimscript/step8_macros.vim index 96e676ce..c64268df 100644 --- a/vimscript/step8_macros.vim +++ b/vimscript/step8_macros.vim @@ -193,7 +193,6 @@ call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) call 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) -call 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 !empty(argv()) call RE('(load-file "' . argv(0) . '")', repl_env) diff --git a/vimscript/step9_try.vim b/vimscript/step9_try.vim index da0ea899..5f826438 100644 --- a/vimscript/step9_try.vim +++ b/vimscript/step9_try.vim @@ -225,7 +225,6 @@ call repl_env.set("*ARGV*", GetArgvList()) call RE("(def! not (fn* (a) (if a false true)))", repl_env) call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) call 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) -call 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 !empty(argv()) try diff --git a/vimscript/stepA_mal.vim b/vimscript/stepA_mal.vim index bdc00bd2..063a8f71 100644 --- a/vimscript/stepA_mal.vim +++ b/vimscript/stepA_mal.vim @@ -226,9 +226,6 @@ call RE("(def! *host-language* \"vimscript\")", repl_env) call RE("(def! not (fn* (a) (if a false true)))", repl_env) call RE("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))", repl_env) call 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) -call RE("(def! inc (fn* [x] (+ x 1)))", repl_env) -call RE("(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))", repl_env) -call 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 !empty(argv()) try diff --git a/wasm/step8_macros.wam b/wasm/step8_macros.wam index 6ecaed28..3c5efaa1 100644 --- a/wasm/step8_macros.wam +++ b/wasm/step8_macros.wam @@ -493,7 +493,6 @@ ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) ($RELEASE ($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)) - ($RELEASE ($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)) ;; Command line arguments diff --git a/wasm/step9_try.wam b/wasm/step9_try.wam index b9a3084a..b70afb1e 100644 --- a/wasm/step9_try.wam +++ b/wasm/step9_try.wam @@ -540,7 +540,6 @@ ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) ($RELEASE ($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)) - ($RELEASE ($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)) ;; Command line arguments diff --git a/wasm/stepA_mal.wam b/wasm/stepA_mal.wam index 5935ef91..3caff191 100644 --- a/wasm/stepA_mal.wam +++ b/wasm/stepA_mal.wam @@ -541,9 +541,6 @@ ($RELEASE ($RE "(def! not (fn* (a) (if a false true)))" $repl_env)) ($RELEASE ($RE "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))" $repl_env)) ($RELEASE ($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)) - ($RELEASE ($RE "(def! inc (fn* [x] (+ x 1)))" $repl_env)) - ($RELEASE ($RE "(def! gensym (let* [counter (atom 0)] (fn* [] (symbol (str \"G__\" (swap! counter inc))))))" $repl_env)) - ($RELEASE ($RE "(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first xs) (let* (c (gensym)) `(let* (~c ~(first xs)) (if ~c ~c (or ~@(rest xs)))))))))" $repl_env)) ;; Command line arguments (local.set $res ($MAP_LOOP_START (global.get $LIST_T))) diff --git a/yorick/step8_macros.i b/yorick/step8_macros.i index c5c5fb84..cf77d268 100644 --- a/yorick/step8_macros.i +++ b/yorick/step8_macros.i @@ -227,7 +227,6 @@ func main(void) 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 (numberof(command_line_args) > 0) { RE, "(load-file \"" + command_line_args(1) + "\")", repl_env diff --git a/yorick/step9_try.i b/yorick/step9_try.i index bb1c2123..b0899741 100644 --- a/yorick/step9_try.i +++ b/yorick/step9_try.i @@ -241,7 +241,6 @@ func main(void) 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 (numberof(command_line_args) > 0) { RE, "(load-file \"" + command_line_args(1) + "\")", repl_env diff --git a/yorick/stepA_mal.i b/yorick/stepA_mal.i index 6b35a129..ea5c2b32 100644 --- a/yorick/stepA_mal.i +++ b/yorick/stepA_mal.i @@ -242,9 +242,6 @@ func main(void) 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 (numberof(command_line_args) > 0) { RE, "(load-file \"" + command_line_args(1) + "\")", repl_env