Skip to content
This repository has been archived by the owner on Nov 1, 2019. It is now read-only.
/ scam Public archive

A toy functional programming language: Scheme, but on a budget

License

Notifications You must be signed in to change notification settings

iafisher/scam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scam

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

Language features

All the regular Scheme stuff:

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

First-class functions:

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

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)
"one"

Lexical closures:

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

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 test_all.sh script to run the test suite.

About

A toy functional programming language: Scheme, but on a budget

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published