Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
mini lisp in OCaml
OCaml
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
test
LICENSE
OMakefile
OMakeroot
README.md

README.md

OCaml-minilisp

OCaml-minilisp is a simple subset of lisp.

Installation

  1. Clone the repo
  2. cd ocaml-minilisp
  3. omake

Test

  1. omake test

Repl

./minilisp
minilisp> (define
(fib n x1 x2)
(if (<= n 0)
x1
(fib (- n 1) x2 (+ x1 x2))))
Func(fib, [n, x1, x2], Cond(Apply(<=, Var(n), Num(0)), Var(x1), Apply(fib, Apply(-, Var(n), Num(1)), Var(x2), Apply(+, Var(x1), Var(x2)))))

minilisp> (fib 100 0 1)
Num(3736710778780434371)

Evaluation of source file

$ cat sample.minilisp 
(define
  (fib n x1 x2)
  (if (<= n 0)
      x1
      (fib (- n 1) x2 (+ x1 x2))))

(print (fib 100 0 1))


$ ./minilisp sample.minilisp 
Num(3736710778780434371)

License

OCaml-minilisp is released under the MIT license.

Author

Mitsunori Komatsu < komamitsu [at] gmail [dot] com >

Something went wrong with that request. Please try again.