Skip to content

heavyairship/swimlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

176 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swim

A simple lisp-like functional programming language and interpreter written in pure Python. Supports (higher order) functions, closures, currying, variable bindings with lexical scoping rules, lists, maps, arithmetic, boolean logic, strings, while-loops, conditionals, sequencing, etc. Lists and maps are persistent data structures.

Here's an example

(fun reverse l:
    (fun helper l a:
        (if l
            (let h (head l));
            (let t (tail l));
            (helper t (push h a))
            a
        )
    );
    (helper l [])
);

(fun map f l:
    (if l
        (let h (head l));
        (let t (tail l));
        (push (f h) (map f t))
        []
    )
);

(fun timestwo n: 
    (* 2 n)
);

(let l [1 2 3 4]);
(reverse (map timestwo l))

The above code evaluates to the list [8 6 4 2].

About

Simple lisp-like language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published