2009-05-13から1日間の記事一覧

今日の夕飯

鶏の竜田揚げ(いなげやのお惣菜) 青椒肉絲 木須肉

SICP問題2.22

square-listが逆の順に答えを作った理由は、cons する際に answer の前(左)に square した結果を追加しているためで、itemsの頭にあったものが右に、次のものがリストの左に入っていくため、並び順が逆になってしまう。まずは修正後のsquare-listが動作を確…

SICP問題2.21

square-listその1 (define (square-list items) (if (null? items) () (cons (square (car items)) (square-list (cdr items))))) square-listその2 (define (square-list items) (map square items))

SICP問題2.20

一つかそれを越える個数の整数をとり、先頭と同じ偶奇数性を持つ引数のリストを返す手続き same-parity (define (same-parity x . y) (define (iter-same-parity same-list rest) (if (null? rest) same-list (if (or (and (even? x) (even? (car rest))) (a…