A lisp interpreter in Haskell based on r6rs
Category | Percentage | Tests |
---|---|---|
01 Basics | 100% | 3/3 |
02 Quote | 100% | 2/2 |
03 Cons Car Cdr | 100% | 5/5 |
04 Arithmetics | 100% | 3/3 |
05 Equalities | 100% | 5/5 |
06 Define | 100% | 2/2 |
07 Conditionals | 100% | 3/3 |
08 Lambda | 100% | 3/3 |
09 Complex programs | 100% | 5/5 |
10 Error handling | 100% | 4/4 |
99 Coding style | 100% | 3/3 |
End scores | 100% | 38/38 |
- Builtins
- Basics (car, cdr, cons, void, ...)
- Predicates (eq?, null?, number?, pair?, ...)
- Arithmetic (+, -, *, div, mod, min, max, even?, odd?, pow, sum, product, ...)
- Comparisons (<, >, <=, >=)
- String comparison (string=?, string<?, string<=?, string>?, string>=?)
- List functions (length, append, reverse, map, filter, foldl, foldr, ...)
- Algorithms (fibonacci, factorial, merge-sort)
- IO (display, newline)
- Load library (load)
- Forms
- Cond
- If
- Let
- Lambda
- Quote
- Set
- Define
- Begin
- REPL
- Read-eval-print loop (interactive)
- Debug commands (show expression in datums / forms)
- Environment commands (show, enter, leave, clear)
$ ./hal --help
Usage: ./hal [FILE]... [OPTION]...
-h --help Show this help and exit
-q --quiet Suppress prompt
-i --interactive Enable interactive mode
-l FILE/DIR PATH --library=FILE/DIR PATH Add a library path
$ ./hal
HAL - Lisp REPL
Type :h to see help
Type :q to quit
> (define add (lambda (a b) (+ a b)))
> add
#<procedure>
> (add 40 2)
42
> (set! add 42)
> add
42
> (fib 21)
10946
> (merge-sort '(39 16 22 24 17 29 18 26 27 3 34 25 10 6 7 12 8 30 2 21 13 36 14 38 32 41 40 4 35 19 5 33 23 9 15 31 28 20 42 37 11 1))
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42)
$ make
or
$ stack build --copy-bins
$ make tests_run
or
$ ./tests.sh