Lisp

Programmer

博客园 首页 新随笔 联系 订阅 管理

1. for a language:
(1) primitive elements
(2) means of combination
(3) means of abstraction

 

2. ;; compute the sum of term(k) where k from a to b by next(a)
(define sum (term a next b)
______(if (> a b)
________0
________(+ (term a) (sum term (next a) next b))))

 

 3. the rights and priviledges of first-class citizens:
(1) to be named by variables
(2) to be passed as arguments to procedures
(3) to be returned as values of procedures
(4) to be incoperated into data structures

 

4. ;;specification of cons
;; (car (cons x y)) = x
;; (cdr (cons x y)) = y
(define (cons a b)
______(lambda (pick)
_____________(cond ((= pick 1) a) ((= pick 2) b))))
(define (car x) (x 1))
(define (cdr x) (x 2))

posted on 2006-03-23 08:44  fei  阅读(178)  评论(0编辑  收藏  举报