Draft exercise suggesting native implementations of some built-in functions.
[jackhill/mal.git] / docs / exercise.md
CommitLineData
0544b52f
NB
1Once you have a working implementation, you may want to implement
2parts of the process inside the MAL language itself. This has no other
3purpose than learning the MAL language. Once it exists, a built-in
4implementation will always be more efficient than a native
5implementation. Also, the functions described in MAL process are
6selected for educative purposes, so portability accross
7implementations does not matter much.
8
9You may easily check your answers by passing them directly to the
10interpreter. They will hide the built-in functions carrying the same
11names, and the usual tests (with REGRESS=1) will check them. The
12`runtest.py` script provide a convenient command-line parameter to
13pass a command like 'load-file' before running the testsuite.
14
15Some solutions are given in the `examples` directory. Feel free to
16submit new solutions, or new exercises.
17
18
19- Implement the following functions with other built-in functions.
20 - `nil?`, `true?` and `false?`
21 - `empty?`
22 - `sequential?`
23
24- Implement `>`, `<=` and `>=` with `<`.
25
26- Implement the following non-recursive functions.
27 - `hash-map`
28 - `list`
29 - `prn`
30 - `swap!`
31
32- Implement `map` with a recursion.
33
34- Implement the `do` special as a non-recursive function. The special
35 form will hide your implementation, so in order to test it, you will
36 need to give it another name and adapt the test accordingly.
37
38- Implement `let*` as a macro that uses `fn*` and recursionn. The same
39 remark applies.
40
41- Implement `apply` as a macro.
42
43- Implement maps using lists.
44 FIXME: Is dissoc use anywhere? It makes this implememtation and the
45 process more complex.
46
47- Implement quoting within MAL.
48
49- Implement macros within MAL.