Created
September 4, 2012 07:59
-
-
Save Liutos/3618255 to your computer and use it in GitHub Desktop.
《Lisp in Small Piece》第9页小小读书笔记
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 这是《Lisp in Small Piece》上第9页的eprogn函数的定义,实际上这样子的定义 | |
;;; 是为了可以让调用eprogn的返回值可以是最后一个被求值的表达式。 | |
(define (eprogn exps env) | |
(if (pair? exps) | |
(if (pair? (cdr exps)) | |
(begin (evaluate (car exps) env) | |
(eprogn (cdr exps) env)) | |
(evaluate (car exps) env)) | |
'())) | |
;;; 如果写成下面这样的定义,那么调用eprogn的返回值就始终是空表'(),这样子就只能够依赖 | |
;;; 参数被求值所带来的副作用了。 | |
(define (eprogn exps env) | |
(if (pair? exps) | |
(begin (evaluate (car exps) env) | |
(eprogn (cdr exps) env)) | |
'())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment