1 /*******************************************************************
3 * A Lisp compiler
, written
in Prolog
9 * A few sample function definitions
, mainly used by me as simple
10 * test cases
for the compiler
. I
'm sure you can come up with
13 *******************************************************************/
20 lisp_append_2(l1, l2) <<==
21 cond( [[null(l1), l2],
23 lisp_append_2(rest(l1),
27 lisp_error(x) <<== setq(y, 5).
30 let([bind(x, 10), bind(y, 20)],
34 let([bind(x, 3), bind(y, 5)],
35 [x, y]). % implicit progn here
38 % maps 'first
' over a list of lists
40 mapcar(function(first), l).
43 <<== defvar(fred, 13).
48 reset_george(val) <<==
53 function(lambda([y], plus(x, y))).
56 scale_list(xs, scale) <<==
57 let([bind(fred, function(lambda([num], times(scale, num))))],
61 make_summer(total) <<==
63 setq(total, plus(total, n)))).
67 let([bind(running_total, 0)],
68 let([bind(summer, function(lambda([n], setq(running_total,
69 plus(running_total, n)))))],