2008-03-08から1日間の記事一覧
mystery によって何が起こるでしょう! (define (mystery x) (define (loop x y) (if (null? x) y (let ((temp (cdr x))) (set-cdr! x y) (loop temp x)))) (loop x '())) (define v (list 'a 'b 'c 'd)) (define w (mystery v)) (print w) ; (d c b a) 見事…
どうなるかって無限ループだよ >< 泣ける!!!! (define (last-pair x) (if (null? (cdr x)) x (last-pair (cdr x)))) (define (make-cycle x) (set-cdr! (last-pair x) x) x) (define z (make-cycle (list 'a 'b 'c))) (last-pair z) last-pair でずっとリ…
set-car! と set-cdr! でリスト構造を変更することができるよ!!というおはなし.append と append! が以下のように定義されているとき, (define (append x y) (if (null? x) y (cons (car x) (append (cdr x) y)))) (define (append! x y) (set-cdr! (last-…