(wat-aro)

生きてます

2015-12-19から1日間の記事一覧

SICP 問題 4.09

;; iteratorの実装 ;; whileの使用例 (while (< i 10) (begin (display i) (newline) (set! i (+ i 1)))) (let while () (if (< i 10) (begin (begin (display i) (newline) (set! i (+ i 1))) (while)))) ;; 破壊的です. (define (while? exp) (tagged-lis…

SICP 問題 4.08

let->combinationの変更ですんでいるのでevalは変更しなくていい. (define (named-let? exp) (symbol? (cadr exp))) (define (named-let-func-name exp) (cadr exp)) (define (named-let-parameters exp) (caddr exp)) (define (named-let-variables exp) (…

SICP 問題 4.07

let*をネストしたletで置き換える. ;; (let* ((x 3) ;; (y (+ x 2)) ;; (z (+ x y 5))) ;; (* x z)) ;; (let ((x 3)) ;; (let ((y (+ x 2))) ;; (let ((z (+ x y 5))) ;; (* x z)))) ;; let* (define (let*? exp) (tagged-list? exp 'let*)) (define (let*-…

SICP 問題 4.06

letを導入. lambdaに変形することで定義する. ;; (let ((a 1) (b 2) (c 3)) ;; (+ a b c)) ;; ((lambda (a b c) ;; (+ a b c)) 1 2 3) (define (let? exp) (tagged-list? exp 'let)) (define (let-parameters exp) (cadr exp)) (define (let-variables exp…