Mercurial > rlm
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/rlm/elisp_example.el Tue Oct 18 00:57:08 2011 -0700 1.3 @@ -0,0 +1,39 @@ 1.4 + 1.5 +;;No BigNum Promotion 1.6 +(defun factorial (n &optional f) 1.7 + (cond ((null f) (factorial n 1)) 1.8 + ((<= n 1) f) 1.9 + (t (factorial (- n 1) (* n f))))) 1.10 + 1.11 +;; No Tail Recursion 1.12 +(defun count (n &optional work) 1.13 + (cond ((<= n 0) work) 1.14 + (t (count (- n 1) (cons n work))))) 1.15 + 1.16 +;;Shallow Dynamic Variables by Default 1.17 +(setq x 3) 1.18 + 1.19 +(defun whatisx () 1.20 + x) 1.21 + 1.22 +(defun frobx () 1.23 + (setq x 5) 1.24 + (whatisx)) 1.25 + 1.26 +(defun mungex (x) 1.27 + (whatisx)) 1.28 + 1.29 +(defun duncant () 1.30 + (print n)) 1.31 + 1.32 +(defun rlm (n) 1.33 + (duncant)) 1.34 + 1.35 +;; no namespaces :( 1.36 + 1.37 +;; compiles to bytecode, very small memory footprint 1.38 + 1.39 +;; LISP 2 1.40 +(reduce + '(1 2 3 4)) ;;doesn't work 1.41 +(reduce (function +) '(1 2 3 4)) ;;have to do this! 1.42 +(reduce #'+ '(1 2 3 4)) ;;this works too...