Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Lisp

This is a lisp interpreter that I wrote following along this book: http://www.buildyourownlisp.com

Compile the interpreter

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

Code Examples

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))}
})

About

Tiny Lisp is a lisp interpreter built from scratch in C. It has basic data types, control flow structures, and macros which let you create anything.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages