Skip to content
A toy functional programming language: Scheme, but on a budget
C Scheme Yacc Makefile Other
Branch: master
Clone or download
Latest commit e89c4cf Jul 10, 2018


A toy functional programming language. Inspired by SICP and Build Your Own Lisp.

Language features

All the regular Scheme stuff:

>>> (+ 1 1)
>>> (define x "Hello, world")
>>> x
"Hello, world"
>>> (define (square x) (* x x))
>>> (square 9)

First-class functions:

>>> (map square (list 1 2 3))
[1 4 9]
>>> ((lambda (x y) (+ x y)) 47 53)

Lists (actually, dynamic arrays) and dictionaries, with a convenient syntax inspired by Python:

>>> (concat ["Scheme" "Racket" "Common Lisp" "Clojure"] ["Scam"])
["Scheme" "Racket" "Common Lisp" "Clojure" "Scam"]
>>> (define dct {1:"one"  2:"two"})
>>> (get dct 1)

Lexical closures:

>>> (define (make-fun x) (lambda (y) (+ x y)))
>>> (define inc-by-10 (make-fun 10))
>>> (inc-by-10 30)

How to compile

At present this project is highly non-portable. It will most likely only work with gcc, possibly only on Ubuntu. At a minimum, you will need to install readline, Flex and Bison. On Ubuntu this can be done with

$ sudo apt-get install libreadline6 libreadline6-dev flex bison

It is recommended you install valgrind (to run the test suite) and a LaTeX compiler (to read the docs), but these are not strictly necessary to compile the project.

Once these dependencies have been satisfied, simply run make in the root directory. An executable file scam will be created, which starts a REPL if run with no arguments. If you have valgrind installed, you can use the script to run the test suite.

You can’t perform that action at this time.