問題5.44 – SICP(計算機プログラムの構造と解釈)その295
問題5.44 compile の振り分け時に定義が上書きされているかを調べる。 (define (compile exp target linkage ct-env) ;; 省略 ((open-code-operator? exp ct-env) (compile-open-code exp target linkage ct-env)) ;; 省略 (else (error "Unkn…続きを読む
問題5.44 compile の振り分け時に定義が上書きされているかを調べる。 (define (compile exp target linkage ct-env) ;; 省略 ((open-code-operator? exp ct-env) (compile-open-code exp target linkage ct-env)) ;; 省略 (else (error "Unkn…続きを読む
問題5.43 4.1.6節の問題4.16で作った scan-out-defines を compile-lambda-body に組み込む (define (compile-lambda-body exp proc-entry ct-env) (let ((formals (lambda-parameters exp))) (append-instruction-sequences (make-i…続きを読む
問題5.42 (define (compile exp target linkage ct-env) ;; 省略 ((variable? exp) (compile-variable exp target linkage ct-env)) ;; 省略 (else (error "Unknown expression type — COMPILE" exp)))) (defin…続きを読む
問題5.41 (define (find-variable var ct-env) (define (frame-iter var frames frame-number) (if (null? frames) ‘not-found (let ((addr (scan-iter var (car frames) frame-number 0))) (if (null? addr) (frame-i…続きを読む
演習2-10 #include <stdio.h> int lower(int c); int main(int argc, char *argv[]) { int c; while((c = getchar()) != EOF) { putchar(lower(c)); } return 0; } int lower(int c) { return (c >= ‘A’ &…続きを読む
問題5.40 (define (compile-lambda-body exp proc-entry ct-env) (let ((formals (lambda-parameters exp))) (append-instruction-sequences (make-instruction-sequence ‘(env proc argl) ‘(env) `(,proc-entry (assi…続きを読む
2.10 代入演算子と式 /* 右端のビットが 1 の場合 b をインクリメントする * x = 141 : 1000 1101 => 141 inc * x >>= 1 : 0100 0110 => 70 * x >>= 1 : 0010 0011 => 35 inc * x >>= 1 : 0001 0001 => 17 inc * …続きを読む
問題5.39 (define (lexical-address-frame-number lexical-address) (car lexical-address)) (define (lexical-address-displacement-number lexical-address) (cadr lexical-address)) (define (make-lexical-address…続きを読む
演習2-8 /* * x = 75, n = 3 * 75 => 0100 1011 * 105 => 0110 1001 */ #include <stdio.h> #include <limits.h> unsigned char rightrot(unsigned char x, int n); int main(int argc, char *argv[…続きを読む
問題5.38 a. 及び b. (define (compile exp target linkage) ;; 省略 ((memq (car exp) ‘(+ – * / =)) (compile-open-code exp target linkage)) ;; 省略 (else (error "Unknown expression type — COMPILE" exp)…続きを読む