ヤドカリ自習室(第二倉庫)

 | 

2009-06-19

CPSメモ 16:18

(define (flatten lst) 
  (define (flatten/cps lst cont)
    (cond ((null? lst) (cont '()))
          ((symbol? lst) (cont (list lst)))
          (else
           (flatten/cps
            (car lst)
            (lambda (f)
              (flatten/cps
               (cdr lst)
               (lambda (r) (cont (append f r)))))))))
  (flatten/cps lst values))
 |