(wat-aro)

生きてます

2016-01-31から1日間の記事一覧

SICP 問題 5.22

appendとappend!をレジスタマシン上に実装する. append (define (append x y) (if (null? x) y (cons (car x) (append (cdr x) y)))) (define append (make-machine '(x y val continue) (list (list 'cons cons) (list 'null? null?) (list 'car car) (lis…

SICP 問題 5.21

schemeで書いた手続きのレジスタマシンを実装する. ;;; a ;;; 再帰的count-leaves (define (count-leaves tree) (cond ((null? tree) 0) ((not (pair? tree)) 1) (else (+ (count-leaves (car tree)) (coutn-leaves (cdr tree)))))) (define recur-count-le…

SICP 問題 5.20

(define x (cons 1 2)) (define y (list x y)) で作られたリスト構造の箱とポインタ表記,メモリーべ宇久田表現をかけ. freeポインタは最初p1にあるとする. 最後freeポインタはp4を指している. p1がxを,p2がyを表している.

SICP 問題 5.19

ラベルから何番目の命令の直前にブレークポイントを入れられるようにする. 実装した手続きのテストはREPLで試したが,テストの記述は省略. (define (set-breakpoint machine label n) ((machine 'set-breakpoint) label n)) (define (proceed-machine mach…