2015-05-14 05:28:55 +00:00
|
|
|
lisp = require './lisp_ch1'
|
|
|
|
{read, readForms} = require './reader'
|
|
|
|
{inspect} = require 'util'
|
2015-05-20 16:41:30 +00:00
|
|
|
|
2015-06-17 19:34:31 +00:00
|
|
|
# ast = read("(begin (set! fact (lambda (x) (if (eq? x 0) 1 (* x (fact (- x 1)))))) (fact 5))")
|
|
|
|
|
|
|
|
# ast = read("(begin (if (lt 4 5) (+ 4 1) (+ 2 1)))")
|
2015-05-20 16:41:30 +00:00
|
|
|
# ast = read("(begin (set! fact 4) fact)")
|
2015-05-20 22:47:51 +00:00
|
|
|
# ast = read("(begin ((lambda (t) (if (lt t 2) (+ 4 1) (+ 2 1))) 1))")
|
|
|
|
|
|
|
|
# ast = read("(begin (set! fact (lambda (x) (+ x x))) (fact 5))")
|
2015-06-17 19:34:31 +00:00
|
|
|
ast = read("(begin (set! fact (lambda (x) (- x 4))) (fact 5))")
|
|
|
|
# ast = read("(begin ((lambda () (+ 5 5))))")
|
2015-05-20 22:47:51 +00:00
|
|
|
|
2015-05-14 05:28:55 +00:00
|
|
|
console.log "Result:", (lisp ast)
|