view 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
line wrap: on
line source

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)))))
8 ;; No Tail Recursion
9 (defun count (n &optional work)
10 (cond ((<= n 0) work)
11 (t (count (- n 1) (cons n work)))))
13 ;;Shallow Dynamic Variables by Default
14 (setq x 3)
16 (defun whatisx ()
17 x)
19 (defun frobx ()
20 (setq x 5)
21 (whatisx))
23 (defun mungex (x)
24 (whatisx))
26 (defun duncant ()
27 (print n))
29 (defun rlm (n)
30 (duncant))
32 ;; no namespaces :(
34 ;; compiles to bytecode, very small memory footprint
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...