2005/04/16

reverseもどきのrvsプロシージャのメモ

(define fishy-rvs
(lambda (tr)
(cond
((null? (cdr tr)) tr)
((null? (cdr (cdr tr))) (cons (car (cdr tr)) (car tr)))
(else (let ((amari-tr (cdr (cdr tr))))
(fishy-rvs
(cons
(cons (car (cdr tr)) (car tr))
amari-tr)))))))

(define car2proper-list
(lambda (ls)
(cons (cons (car ls) ()) (cdr ls))))

(define rvs
(lambda (tr)
(if (list? tr)
(fishy-rvs (car2proper-list tr))
"it's not list!")))

なんかもっとかっこよくならないものか。

No comments :