数据即操作·寓意深刻- -| 回首页 | 2005年索引 | - -宏论·注脚

数据即操作·实例- -

                                      

拉一段程序,仍然是“复数”的例子:

(define (make-complex real image)
  (define (dispatch command)
    (cond ((eq? command 'get-real) real)
          ((eq? command 'get-image) image)
          (else "DONNOT SUPPORT THIS OPERATION -- COMPLEX")))
  dispatch)

(define (get-real complex)
  (complex 'get-real))

(define (get-image complex)
  (complex 'get-image))

(define complex1 (make-complex 2 3))
(get-real complex1)
(get-image complex1)

-------

2
3

- 作者: 透明 2005年07月15日, 星期五 14:19

Trackback

你可以使用这个链接引用该篇日志 http://publishblog.blogdriver.com/blog/tb.b?diaryID=816992

回复

- 评论人:爱已经破碎

Mon Jul 25 10:52:03 CST 2005  作者邮箱  作者Blog

。。。。。。。。。。。

- 评论人:nulid

Sun Jul 17 21:03:43 CST 2005  作者邮箱  作者Blog

http://nulia.3322.org

http://nuli2.8800.org

http://nulic.6600.org

http://nulid.2288.org

http://nulie.3322.org

评论内容: