昨晩の読書会
問題 4.4 で eval-and と eval-or は似たカンジなのでまるっとまとめちゃえ、と言いつつ以下なソレがでっち上がった。
(define (eval-and-or f exp env) (if (f (eval (first-operand exp) env)) (f #t) (if (no-operands? (rest-operand exp)) (f #f) (eval-and-or f (rest-operand exp) env)))) (define (eval-and exp env) (eval-and-or not exp env)) (define (eval-or exp env) (eval-and-or (lambda (x) x) exp env))
最初は
以下なカンジでバラで定義。
(define (eval-and exp env) (if (eval (first-operand exp) env) (if (no-operands? (rest-operand exp)) #t (eval-and (rest-operand exp) env)) #f)) (define (eval-or exp env) (if (eval (first-operand exp) env) #t (if (no-operands? (rest-operand exp)) #f (eval-and (rest-operand exp) env))))
なんとなく python のコーディングルールの話から scheme にはそんなのあるんスか? みたいな話になって、「字下げが綺麗に階段になってたら OK みたいな話を聞いた事があるなぁ」などと言ってて、それならこーすれば、という話から上のソレがでっち上がった次第ッス。
で、そこで
(lambda (x) x)
なソレって手続きとして名前が付いてるはずなんだけど名前が思い出せず、限りある読書会の時間を Google 先生への質問に使ったにも関わらず分かりませんでしたorz
どなたかご存知の方、ご教示頂ければ幸いに存じますです。