Name: Anonymous 2011-09-09 22:04
JavaScript has much in common with Scheme. It is a dynamic language. It has a flexible datatype (arrays) that can easily simulate s-expressions. And most importantly, functions are lambdas.
Because of this deep similarity, all of the functions in The Little Schemer can be written in JavaScript. The syntaxes of these two languages are very different, so some transformation rules are needed.
Because of this deep similarity, all of the functions in The Little Schemer can be written in JavaScript. The syntaxes of these two languages are very different, so some transformation rules are needed.
(define foo (lambda (a b c) (body))) | var foo = function (a, b, c) { return body; };
(foo a b c) | foo(a, b, c);
(and p1 p2 ... pn) | (p1 && p2 ... && pn)
(quote (a b c)) | ['a', ['b', ['c']]]
foo? | isFoo