I am going to put scheme away for time. I found MIT modify its curriculum for
the interpretion of computer program, they substituted python language for scheme
language.
Python is a interesting and useful language. However, in my eyes, its flexibility
and expression is not more than scheme.
I studyed prolog language. It is easy to implement in scheme. I studyed Haskell too.
If a scheme programmer learning Haskell, he can pick out the secret under color of
Haskell grammer. What is lazy evaluation? If you know how to implement the lazy evaluation,
the problem is so easy for you. Haskell is just a little sister of scheme.
(defun in-set (e ls)
(cond ((null ls) nil)
((equal e (car ls)) t)
(t (in-set e (cdr ls)))))
(defmacro map (pred ls)
(list 'mapcar pred ls))
(map (lambda (x) (+ 1 x)) (list 1 2 3))
(mapcar (lambda (x) (car x)) (list (cons 1 2) (cons 3 4) (cons 5 6)))
(defun reverse-list (ls)
(let (val)
(dolist (e ls val)
(setq val (cons e val)))))
(defun set (ls)
(let (rs)
(dolist (elt ls rs)
(if (not (in-set elt rs))
(setq rs (cons elt rs))))))
(set (list 1 2 3 3 4 8))
(defun fib (n)
(if (or (= n 0) (= n 1)) 1
(+ (fib (- n 1)) (fib (- n 2)))))
(fib 10)