This is a lisp interpreter that I wrote following along this book: http://www.buildyourownlisp.com
To compile run
foo@bar:~$ cc -std=c99 -Wall tlisp.c mpc.c -ledit -lm -o tiny_lisp
Then to run the REPL:
foo@bar:~$ ./tiny_lisp
or to run a file
foo@bar:~$ ./tiny_lisp std.tlsp
Naive recursive Fibonacci function in tiny lisp
(fun {fib n} {
select
{ (== n 0) 0 }
{ (== n 1) 1 }
{ otherwise (+ (fib (- n 1)) (fib (- n 2))) }
})
Take n objects from a list
(fun {take n l} {
if (== n 0)
{nil}
{join (head l) (take (- n 1) (tail l))}
})
Apply a function to each element in list (map function)
(fun {map f l} {
if (== l nil)
{nil}
{join (list (f (fst l))) (map f (tail l))}
})