### Install Dependencies on Ubuntu Source: https://github.com/kanaka/mal/blob/master/impls/cpp/README.md Install the necessary compiler and library packages using apt-get. ```bash apt-get install clang-3.5 libreadline-dev make ``` -------------------------------- ### Install Prerequisites on Ubuntu Source: https://github.com/kanaka/mal/blob/master/docs/graph/README.md Install necessary tools on Ubuntu systems using apt-get. ```bash sudo apt-get install gh sudo apt-get golang ``` -------------------------------- ### Try/Catch and Environment Setup Source: https://github.com/kanaka/mal/blob/master/docs/cheatsheet.html Configures the host language environment and executes the main REPL loop. ```text EVAL(ast, env): - set *host-language* in repl_env to host language name main(args): rep("(println (str \"Mal [\" *host-language* \"]\"))") ``` -------------------------------- ### Start MAL REPL (Docker) Source: https://context7.com/kanaka/mal/llms.txt Instructions to start the MAL Read-Eval-Print Loop using Docker, applicable to any implementation. ```bash # Using Docker (any implementation) make DOCKERIZE=1 "repl^js" ``` -------------------------------- ### Start Self-Hosted REPL Source: https://github.com/kanaka/mal/blob/master/README.md Start the REPL for the self-hosted implementation. Use MAL_IMPL to set the host language, defaulting to JavaScript. ```makefile make MAL_IMPL=IMPL "repl^mal^stepX" # e.g. make "repl^mal^step2" # js is default make MAL_IMPL=ruby "repl^mal^step2" make MAL_IMPL=python3 "repl^mal" ``` -------------------------------- ### Setup mal on RISC OS Source: https://github.com/kanaka/mal/blob/master/impls/bbc-basic/README.md Initialize the environment for running mal on RISC OS. ```bash *Dir bbc-basic.riscos *Run setup ``` -------------------------------- ### Start MAL REPL (Node.js) Source: https://context7.com/kanaka/mal/llms.txt Instructions to start the MAL Read-Eval-Print Loop using the Node.js implementation. ```bash # Using Node.js implementation cd impls/js node stepA_mal.js # Mal [javascript] # user> ``` -------------------------------- ### Initialize REPL and Core Definitions Source: https://github.com/kanaka/mal/blob/master/process/step8_macros.txt Setup the environment and define core Mal functions using the host language and Mal itself. ```pseudo-code repl_env = new Env() rep(str): return PRINT(EVAL(READ(str),repl_env)) ;; core.EXT: defined using the host language. core.ns.map((k,v) -> (repl_env.set(k, v))) repl_env.set('eval, (ast) -> EVAL(ast, repl-env)) repl_env.set('*ARGV*, cmdline_args[1..]) ;; core.mal: defined using the language itself rep("(def! not (fn* (a) (if a false true)))") rep("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))") rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"); ``` -------------------------------- ### Install Prerequisites on macOS Source: https://github.com/kanaka/mal/blob/master/docs/graph/README.md Install necessary tools on macOS systems using Homebrew. ```bash brew install gh brew install go ``` -------------------------------- ### Start MAL REPL (Python) Source: https://context7.com/kanaka/mal/llms.txt Instructions to start the MAL Read-Eval-Print Loop using the Python 3 implementation. ```bash # Using Python implementation cd impls/python3 python3 stepA_mal.py # Mal [python] # user> ``` -------------------------------- ### Web REPL Initialization Source: https://github.com/kanaka/mal/blob/master/docs/index.html JavaScript setup for the Mal Web REPL using the jqconsole library. ```JavaScript $(function() { // Creating the console. window.jqconsole = $('#console').jqconsole(null, 'user> '); printer.println = function () { var str = Array.prototype.join.call(arguments, " ") jqconsole.Write(str + "\n", 'jqconsole-output'); } rep("(println (str \"Mal [\" *host-language* \"]\"))"); jq_load_history(jqconsole); // Abort prompt on Ctrl+C. jqconsole.RegisterShortcut('C', function() { jqconsole.AbortPrompt(); handler(); }); // Move to line start Ctrl+A. jqconsole.RegisterShortcut('A', function() { jqconsole.MoveToStart(); handler(); }); // Move to line end Ctrl+E. jqconsole.RegisterShortcut('E', function() { jqconsole.MoveToEnd(); handler(); }); jqconsole.RegisterMatching('{', '}', 'brace'); jqconsole.RegisterMatching('(', ')', 'paren'); jqconsole.RegisterMatching('[', ']', 'bracket'); jqconsole.RegisterMatching('"', '"', 'dquote'); // Handle a command. var handler = function(line) { if (line) { try { jqconsole.Write(rep(line) + '\n', 'jqconsole-return'); } catch (exc) { if (exc instanceof reader.BlankException) { return; } if (exc.stack) { jqconsole.Write(exc.stack + '\n', 'jqconsole-error'); } else { jqconsole.Write(exc + '\n', 'jqconsole-error'); } } jq_save_history(jqconsole); } jqconsole.Prompt(true, handler); /* jqconsole.Prompt(true, handler, function(command) { // Continue line if can't compile the command. try { Function(command); } catch (e) { if (/[\{\(]$/.test(command)) { return 1; } else { return 0; } } return false; }); */ }; // Initiate the first prompt. handler(); }); ``` -------------------------------- ### Running SML-MAL Example Source: https://github.com/kanaka/mal/blob/master/impls/sml/README.md Demonstrates running the SML-MAL interpreter and executing a Lisp function. Requires building the 'mal' binary first. ```shell $ make dist $ ./mal Mal [sml] user> (map (fn* (x) (println "Odelay!")) [1 2 3 4 5]) Odelay! Odelay! Odelay! Odelay! Odelay! (nil nil nil nil nil) user> ``` -------------------------------- ### Run BBC BASIC V Mal Implementation on RISC OS Source: https://github.com/kanaka/mal/blob/master/README.md For RISC OS, navigate to the 'bbc-basic.riscos' directory, run the 'setup' script, and then execute the implementation using '*Run stepX_YYY'. ```bash *Dir bbc-basic.riscos *Run setup *Run stepX_YYY ``` -------------------------------- ### Run Go implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires Go installed on the path. ```bash cd impls/go make ./stepX_YYY ``` -------------------------------- ### Diff Command Example Source: https://github.com/kanaka/mal/blob/master/process/guide.md Compares the pseudocode for step 8 and step 9 to show the changes made during this step. ```bash diff -u ../../process/step8_macros.txt ../../process/step9_try.txt ``` -------------------------------- ### Start REPL for an Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Launch the Read-Eval-Print Loop for a specific implementation and step. If the step is omitted, 'stepA' is used by default. ```makefile make "repl^IMPL^stepX" # e.g make "repl^ruby^step3" make "repl^ps^step4" ``` ```makefile make "repl^IMPL" # e.g make "repl^ruby" make "repl^ps" ``` -------------------------------- ### Run miniMAL implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires the miniMAL interpreter installed via npm. ```bash cd impls/miniMAL # Download miniMAL and dependencies npm install export PATH=`pwd`/node_modules/minimal-lisp/:$PATH # Now run mal implementation in miniMAL miniMAL ./stepX_YYY ``` -------------------------------- ### Run CoffeeScript implementation Source: https://github.com/kanaka/mal/blob/master/README.md Install coffee-script globally before running. ```bash sudo npm install -g coffee-script cd impls/coffee coffee ./stepX_YYY ``` -------------------------------- ### Execute Scala Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires Scala and sbt installed. ```bash cd impls/scala sbt 'run-main stepX_YYY' # OR sbt compile scala -classpath target/scala*/classes stepX_YYY ``` -------------------------------- ### Define initial REPL environment in Python Source: https://github.com/kanaka/mal/blob/master/process/guide.md Example of an associative structure mapping symbols to numeric functions. ```python repl_env = {'+': lambda a,b: a+b, '-': lambda a,b: a-b, '*': lambda a,b: a*b, '/': lambda a,b: int(a/b)} ``` -------------------------------- ### Install NPM Dependencies Source: https://github.com/kanaka/mal/blob/master/docs/graph/README.md Install project dependencies via npm. ```bash npm install ``` -------------------------------- ### Initialize Directories Source: https://github.com/kanaka/mal/blob/master/docs/graph/README.md Create the logs directory and navigate to it. ```bash mkdir -p docs/graph/logs cd docs/graph/logs ``` -------------------------------- ### Create implementation directory Source: https://github.com/kanaka/mal/blob/master/process/guide.md Set up a dedicated folder for your specific language implementation. ```bash mkdir impls/quux ``` -------------------------------- ### Install Readline on Mac OSX Source: https://github.com/kanaka/mal/blob/master/impls/cpp/README.md Use Homebrew to install the GNU Readline dependency required for compilation. ```bash brew install readline ``` -------------------------------- ### Build and Run C Mal Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Navigate to the C implementation directory and use 'make' to build. Then, execute the compiled program with './stepX_YYY'. Requires glib, libffi6, libgc, and either libedit or readline. ```bash cd impls/c make ./stepX_YYY ``` -------------------------------- ### Build and Run Second C Mal Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Navigate to the C.2 implementation directory and use 'make' to build. Then, execute the compiled program with './stepX_YYY'. Requires libedit, libgc, libdl, and libffi. ```bash cd impls/c.2 make ./stepX_YYY ``` -------------------------------- ### Get Milliseconds Since Epoch using 'date' command Source: https://github.com/kanaka/mal/blob/master/docs/Hints.md Use this shell command as a fallback if your language lacks a native way to get milliseconds since epoch. This method is limited to Linux/UNIX environments. ```shell date +%s%3N ``` -------------------------------- ### Execute PostScript Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires Ghostscript to be installed. ```bash cd impls/ps gs -q -dNODISPLAY -I./ stepX_YYY.ps ``` -------------------------------- ### Build and run Kotlin implementation Source: https://github.com/kanaka/mal/blob/master/README.md Uses make to build the jar file. ```bash cd impls/kotlin make java -jar stepX_YYY.jar ``` -------------------------------- ### Run Step A Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the tests for Step A using the make command. This verifies the implementation before proceeding to self-hosting. ```bash make "test^quux^stepA" ``` -------------------------------- ### View help for Makefile Source: https://github.com/kanaka/mal/blob/master/README.md Displays available targets and options. ```bash make help ``` -------------------------------- ### Run JavaScript/Node implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires npm install for dependencies before execution. ```bash cd impls/js npm install node stepX_YYY.js ``` -------------------------------- ### Run Fantom implementation Source: https://github.com/kanaka/mal/blob/master/README.md Build the pod before running. ```bash cd impls/fantom make lib/fan/stepX_YYY.pod STEP=stepX_YYY ./run ``` -------------------------------- ### Build and run WebAssembly implementation Source: https://github.com/kanaka/mal/blob/master/README.md Supports multiple runtimes including node, wasmtime, wasmer, wax, wace, and warpy. ```bash cd impls/wasm # node make wasm_MODE=node ./run.js ./stepX_YYY.wasm # wasmtime make wasm_MODE=wasmtime wasmtime --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm # wasmer make wasm_MODE=wasmer wasmer run --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm # wax make wasm_MODE=wax wax ./stepX_YYY.wasm # wace make wasm_MODE=wace_libc wace ./stepX_YYY.wasm # warpy make wasm_MODE=warpy warpy --argv --memory-pages 256 ./stepX_YYY.wasm ``` -------------------------------- ### Example Mal macro for dynamic binding Source: https://github.com/kanaka/mal/blob/master/impls/java-truffle/README.md A macro that could potentially bind a symbol at runtime. ```Mal (fn* [b] (if b `(def! y 42))) ``` -------------------------------- ### Run Step 3 Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for the environment implementation. ```make make "test^quux^step3" ``` -------------------------------- ### Mal Datatypes Source: https://github.com/kanaka/mal/blob/master/docs/index.html Examples of basic Mal data structures including maps, lists, vectors, and scalars. ```Mal {"key1" "val1", "key2" 123} ``` ```Mal (1 2 3 "four") ``` ```Mal [1 2 3 4 "a" "b" "c" 1 2] ``` ```Mal a-symbol, "a string", :a_keyword, 123, nil, true, false ``` -------------------------------- ### Build and run VHDL implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested with GHDL 0.29. ```bash cd impls/vhdl make ./run_vhdl.sh ./stepX_YYY ``` -------------------------------- ### Run step 2 tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for step 2 using make. ```bash make "test^quux^step2" ``` -------------------------------- ### Example Mal function with potential dynamic binding Source: https://github.com/kanaka/mal/blob/master/impls/java-truffle/README.md A Mal function demonstrating how a symbol might not be lexically scoped. ```Mal (def! f (fn* [x b] (do (who-knows? b) y))) ``` -------------------------------- ### Build Zig implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested on Zig 0.5. ```bash cd impls/zig zig build stepX_YYY ``` -------------------------------- ### Run Picolisp implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires libreadline and Picolisp 3.1.11 or later. ```bash cd impls/picolisp ./run ``` -------------------------------- ### Build and run Nim implementation Source: https://github.com/kanaka/mal/blob/master/README.md Supports building via make or nimble. ```bash cd impls/nim make # OR nimble build ./stepX_YYY ``` -------------------------------- ### Reduce to Get First Element Source: https://github.com/kanaka/mal/blob/master/docs/exercises.md This reduce operation returns the first element encountered in the sequence, effectively ignoring subsequent elements. ```MAL (reduce (fn* [_ x] x) nil xs) ``` -------------------------------- ### Build and run Objective C implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested on Linux and OS X. ```bash cd impls/objc make ./stepX_YYY ``` -------------------------------- ### Access PHP superglobal variables in Mal Source: https://github.com/kanaka/mal/blob/master/impls/php/README.md Access PHP superglobal variables, such as `$_SERVER`, using the `get` function and the `php/_SERVER` namespace. ```mal (get php/_SERVER "PHP_SELF") ``` -------------------------------- ### Example of eval usage Source: https://github.com/kanaka/mal/blob/master/process/guide.md Demonstrates how to use the `eval` function to execute Mal code represented as a list. This allows for dynamic execution of Mal programs. ```mal (def! mal-prog (list + 1 2)) (eval mal-prog) ``` -------------------------------- ### Build and run Vala implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires valac and libreadline-dev. ```bash cd impls/vala make ./stepX_YYY ``` -------------------------------- ### Environment Class Definition Source: https://github.com/kanaka/mal/blob/master/process/step3_env.txt Defines the Environment class used for managing variable scopes. It supports setting and getting variables, with nested environments for outer scopes. ```python class Env (outer=null) data = hash_map() set(k,v): return data.set(k,v) get(k): return data.has(k) ? data.get(k) : (outer ? outer.get(k) : null) ``` -------------------------------- ### Reduce for Maximum Value Source: https://github.com/kanaka/mal/blob/master/docs/exercises.md This reduce operation finds the maximum value in a sequence `xs` starting with an initial accumulator of 0. It might be incorrect if `xs` contains only negative numbers. ```MAL (reduce (fn* [acc x] (if (< acc x) x acc)) 0 xs) ``` -------------------------------- ### Build and run NASM implementation Source: https://github.com/kanaka/mal/blob/master/README.md Written for x86-64 Linux. ```bash cd impls/nasm make ./stepX_YYY ``` -------------------------------- ### Mal Sumdown Macro Definition Source: https://github.com/kanaka/mal/blob/master/impls/java-truffle/README.md Defines a recursive macro 'sumdown-via-macro*' and a helper macro 'sumdown-via-macro2' in Mal. These examples illustrate Mal's macro system, including tail-recursive macros that can lead to performance issues if not handled carefully. ```mal (defmacro! sumdown-via-macro* (fn* [acc n] `(if (<= ~n 0) ~acc (sumdown-via-macro* ~(+ acc n) ~(- n 1))))) ``` ```mal (defmacro! sumdown-via-macro2 (fn* [n] `(sumdown-via-macro* 0 ~(eval n)))) ``` -------------------------------- ### Compare Step 6 and Step 7 Implementation Source: https://github.com/kanaka/mal/blob/master/process/guide.md Use the diff command to identify the necessary changes between the previous and current project steps. ```bash diff -u ../../process/step6_file.txt ../../process/step7_quote.txt ``` -------------------------------- ### Run Step 7 Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for the quasiquote implementation using the make command. ```bash make "test^quux^step7" ``` -------------------------------- ### Run Janet implementation Source: https://github.com/kanaka/mal/blob/master/README.md Execute the Janet implementation. ```bash cd impls/janet janet ./stepX_YYY.janet ``` -------------------------------- ### Run Step 6 Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for step 6 using the make command. ```bash make "test^quux^step6" ``` -------------------------------- ### Create and Use Hash-Maps in MAL Source: https://context7.com/kanaka/mal/llms.txt Demonstrates various ways to create and manipulate hash-maps, including literal syntax, using keywords as keys, checking for map types, retrieving values, checking for key existence, adding/updating entries, removing entries, and accessing all keys and values. ```clojure ;; Create hash-maps (hash-map "a" 1 "b" 2) ;=> {"a" 1 "b" 2} ``` ```clojure ;; Literal syntax {"name" "Alice" "age" 30} ;=> {"name" "Alice" "age" 30} ``` ```clojure ;; Using keywords as keys {:name "Bob" :age 25} ;=> {:name "Bob" :age 25} ``` ```clojure ;; Check if value is a map (map? {:a 1}) ;=> true ``` ```clojure ;; Get values (get {"a" 1 "b" 2} "a") ;=> 1 (get {"a" 1} "missing") ;=> nil ``` ```clojure ;; Check for keys (contains? {"a" 1 "b" 2} "a") ;=> true (contains? {"a" 1 "b" 2} "c") ;=> false ``` ```clojure ;; Add/update entries (returns new map) (assoc {"a" 1} "b" 2 "c" 3) ;=> {"a" 1 "b" 2 "c" 3} ``` ```clojure ;; Remove entries (returns new map) (dissoc {"a" 1 "b" 2 "c" 3} "b") ;=> {"a" 1 "c" 3} ``` ```clojure ;; Get all keys and values (keys {"a" 1 "b" 2}) ;=> ("a" "b") (vals {"a" 1 "b" 2}) ;=> (1 2) ``` -------------------------------- ### Build mal-web.php Source: https://github.com/kanaka/mal/blob/master/impls/php/README.md Build the `mal-web.php` executable from the command line. ```bash cd mal/php make mal-web.php ``` -------------------------------- ### Run Self-Hosted Mal Steps Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute your Step A Mal implementation using the file argument mode to run each step of the Mal implementation itself. This is crucial for testing self-hosting capabilities. ```bash ./stepA_mal.qx ../mal/step1_read_print.mal ``` ```bash ./stepA_mal.qx ../mal/step2_eval.mal ``` ```bash ./stepA_mal.qx ../mal/step9_try.mal ``` ```bash ./stepA_mal.qx ../mal/stepA_mal.mal ``` -------------------------------- ### Run Io implementation Source: https://github.com/kanaka/mal/blob/master/README.md Execute the Io implementation. ```bash cd impls/io io ./stepX_YYY.io ``` -------------------------------- ### Build and Run C++ Mal Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Navigate to the C++ implementation directory and use 'make' to build. This requires g++-4.9 or clang++-3.5 and a readline compatible library. You can specify the C++ compiler using CXX=clang++-3.5. ```makefile cd impls/cpp make # OR make CXX=clang++-3.5 ./stepX_YYY ``` -------------------------------- ### Run Mal Implementation with Docker Source: https://github.com/kanaka/mal/blob/master/README.md Use this command to launch the REPL for a specific Mal implementation using Docker. Replace IMPL with the implementation directory name and stepX with the step to run. If no step is specified, the default stepA is used. ```makefile make DOCKERIZE=1 "repl^IMPL^stepX" # OR stepA is the default step: make DOCKERIZE=1 "repl^IMPL" ``` -------------------------------- ### Run ChucK implementation Source: https://github.com/kanaka/mal/blob/master/README.md Execute the ChucK implementation of Mal. ```bash cd impls/chuck ./run ``` -------------------------------- ### Run Yorick implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested on Yorick 2.2.04. ```bash cd impls/yorick yorick -batch ./stepX_YYY.i ``` -------------------------------- ### Build MAL with Custom Binary Path Source: https://github.com/kanaka/mal/blob/master/impls/common-lisp/README.org Specify both the implementation nickname and the absolute path to the binary using environment variables. ```sh cd common-lisp ; LISP=ccl CCL=~/.roswell/impls/x86-64/linux/ccl-bin/1.11/lx86cl64 make ``` -------------------------------- ### Build and run Object Pascal implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested with Free Pascal compiler on Linux. ```bash cd impls/objpascal make ./stepX_YYY ``` -------------------------------- ### Build and run Standard ML implementation Source: https://github.com/kanaka/mal/blob/master/README.md Supports Poly/ML, MLton, and Moscow ML via makefile modes. ```bash cd impls/sml # Poly/ML make sml_MODE=polyml ./stepX_YYY # MLton make sml_MODE=mlton ./stepX_YYY # Moscow ML make sml_MODE=mosml ./stepX_YYY ``` -------------------------------- ### Run Step 4 Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for the step 4 implementation using the make utility. ```bash make "test^quux^step4" ``` -------------------------------- ### Run Crystal implementation Source: https://github.com/kanaka/mal/blob/master/README.md Use make to build for tests or run directly via crystal. ```bash cd impls/crystal crystal run ./stepX_YYY.cr # OR make # needed to run tests ./stepX_YYY ``` -------------------------------- ### Run Wren implementation Source: https://github.com/kanaka/mal/blob/master/README.md Tested on Wren 0.2.0. ```bash cd impls/wren wren ./stepX_YYY.wren ``` -------------------------------- ### Compare Step 9 and Step A Pseudocode Source: https://github.com/kanaka/mal/blob/master/process/guide.md Use this diff command to compare the pseudocode between step 9 and step A to understand the changes required for self-hosting. ```bash diff -u ../../process/step9_try.txt ../../process/stepA_mal.txt ``` -------------------------------- ### Run GNU Make implementation Source: https://github.com/kanaka/mal/blob/master/README.md Executes the specified Makefile. ```bash cd impls/make make -f stepX_YYY.mk ``` -------------------------------- ### Create Local Bindings with let* Source: https://context7.com/kanaka/mal/llms.txt Establishes a new environment with local bindings. Bindings are processed sequentially, allowing later definitions to reference earlier ones. ```clojure ;; Simple local binding (let* (x 10) x) ;=> 10 ;; Multiple bindings (sequential) (let* (x 5 y (* x 2)) (+ x y)) ;=> 15 ;; Bindings can reference previous bindings (let* (a 1 b (+ a 1) c (+ b 1)) (list a b c)) ;=> (1 2 3) ;; Local bindings don't affect outer scope (def! outer 100) (let* (outer 5) outer) ;=> 5 outer ;=> 100 ;; Nested let* expressions (let* (x 10) (let* (y 20) (+ x y))) ;=> 30 ``` -------------------------------- ### Build and run Visual Basic.NET implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires Mono VB compiler and runtime. ```bash cd impls/vb make mono ./stepX_YYY.exe ``` -------------------------------- ### Build and run Java implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires maven2 to build and execute the specified step. ```bash cd impls/java mvn compile mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY # OR mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS" ``` -------------------------------- ### Run Step 8 Tests Source: https://github.com/kanaka/mal/blob/master/process/guide.md Execute the test suite for the macro implementation. ```bash make "test^quux^step8" ``` -------------------------------- ### Compare Step 3 and Step 4 Implementation Source: https://github.com/kanaka/mal/blob/master/process/guide.md Use the diff command to identify the changes required between step 3 and step 4. ```bash diff -u ../../process/step3_env.txt ../../process/step4_if_fn_do.txt ``` -------------------------------- ### Execute Ruby Implementation Source: https://github.com/kanaka/mal/blob/master/README.md Standard Ruby implementation. ```bash cd impls/ruby ruby stepX_YYY.rb ``` -------------------------------- ### Standard Dockerfile Template Source: https://github.com/kanaka/mal/blob/master/docs/FAQ.md Recommended base structure for implementation Dockerfiles. ```dockerfile FROM ubuntu:24.04 MAINTAINER Your Name LABEL org.opencontainers.image.source=https://github.com/kanaka/mal LABEL org.opencontainers.image.description="mal test container: Your_Implementation" ########################################################## # General requirements for testing or common across many # implementations ########################################################## RUN apt-get -y update # Required for running tests RUN apt-get -y install make python3 RUN ln -sf /usr/bin/python3 /usr/bin/python # Some typical implementation and test requirements RUN apt-get -y install curl libreadline-dev libedit-dev RUN mkdir -p /mal WORKDIR /mal ########################################################## # Specific implementation requirements ########################################################## ... Your packages ... ``` -------------------------------- ### Run PHP implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires the PHP command line interface. ```bash cd impls/php php stepX_YYY.php ``` -------------------------------- ### Build and run OCaml implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires make to build. ```bash cd impls/ocaml make ./stepX_YYY ``` -------------------------------- ### Run Elixir implementation Source: https://github.com/kanaka/mal/blob/master/README.md Use iex for interactive line editing. ```bash cd impls/elixir mix stepX_YYY # Or with readline/line editing functionality: iex -S mix stepX_YYY ``` -------------------------------- ### Run Emacs Lisp implementation Source: https://github.com/kanaka/mal/blob/master/README.md Recommended to use rlwrap for readline support. ```bash cd impls/elisp emacs -Q --batch --load stepX_YYY.el # with full readline support rlwrap emacs -Q --batch --load stepX_YYY.el ``` -------------------------------- ### Run Visual Basic Script implementation Source: https://github.com/kanaka/mal/blob/master/README.md Requires .NET 2.0/3.0/3.5 on Windows. ```bash cd impls\vbs install.vbs cscript -nologo stepX_YYY.vbs ``` -------------------------------- ### Build Docker Image Source: https://github.com/kanaka/mal/blob/master/docs/FAQ.md Command to build and tag the implementation's Docker image. ```makefile make "docker-build^[IMPL_NAME]" ``` -------------------------------- ### Run Fennel implementation Source: https://github.com/kanaka/mal/blob/master/README.md Execute the Fennel implementation. ```bash cd impls/fennel fennel ./stepX_YYY.fnl ``` -------------------------------- ### Build Loccount Source: https://github.com/kanaka/mal/blob/master/docs/graph/README.md Clone the loccount repository and build it using make. ```bash git clone https://gitlab.com/esr/loccount make -C loccount ``` -------------------------------- ### Create a web-runnable Mal script Source: https://github.com/kanaka/mal/blob/master/impls/php/README.md Create a Mal script and a symlink to `mal-web.php` to make it executable via a web server. ```bash echo '(println "Hello world!")' > myscript.mal ln -s mal-web.php myscript.php ``` -------------------------------- ### Build and run Java Truffle implementation Source: https://github.com/kanaka/mal/blob/master/README.md Optimized for GraalVM using the Truffle framework. ```bash cd impls/java-truffle ./gradlew build STEP=stepX_YYY ./run ```