Lisp Scheme Part19at TECH
Lisp Scheme Part19 - 暇つぶし2ch374:デフォルトの名無しさん
08/01/30 23:31:50
>>351
余計なカッコがつくのはbeta-reduceで余計なカッコがついてしまうのが原因だった。
;;β変換
(define (beta-reduce l m)
(let ((arg (caadr l))
(body (cddr l))) ;x0 -> (x0), (x y) -> ((x y))
(car (subst arg m body)))) ;(x-) -> x0,((x y)) -> (x y)
α変換の付け替えが違っていた。
(define (alfa-conversion1 f)
(cond ((and (symbol? f)(bound? f)) (bound? f))
((and (symbol? f)(not(bound? f)) f))
((number? f) f)
((null? (cdr f)) (alfa-conversion1 (car f)))
((and (eq? (car f) 'lambda)(symbol? (caadr f)))
(let ((new (genvar 'gen)))
(bound (caadr f) new)
(list 'lambda (list new) (alfa-conversion1 (caddr f)))))
(else (list (alfa-conversion1 (car f))(alfa-conversion1 (cadr f))))))



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch