comparison src/rlm/elisp_example.el @ 0:78a630e650d2

initial import
author Robert McIntyre <rlm@mit.edu>
date Tue, 18 Oct 2011 00:57:08 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:78a630e650d2
1
2 ;;No BigNum Promotion
3 (defun factorial (n &optional f)
4 (cond ((null f) (factorial n 1))
5 ((<= n 1) f)
6 (t (factorial (- n 1) (* n f)))))
7
8 ;; No Tail Recursion
9 (defun count (n &optional work)
10 (cond ((<= n 0) work)
11 (t (count (- n 1) (cons n work)))))
12
13 ;;Shallow Dynamic Variables by Default
14 (setq x 3)
15
16 (defun whatisx ()
17 x)
18
19 (defun frobx ()
20 (setq x 5)
21 (whatisx))
22
23 (defun mungex (x)
24 (whatisx))
25
26 (defun duncant ()
27 (print n))
28
29 (defun rlm (n)
30 (duncant))
31
32 ;; no namespaces :(
33
34 ;; compiles to bytecode, very small memory footprint
35
36 ;; LISP 2
37 (reduce + '(1 2 3 4)) ;;doesn't work
38 (reduce (function +) '(1 2 3 4)) ;;have to do this!
39 (reduce #'+ '(1 2 3 4)) ;;this works too...