Open Source WEB

##(link2sicp "book-Z-H-15.html#%_thm_2.39" "Exercise 2.39")

解答例

fold-right版

(define (reverse sequence)
  (fold-right (lambda (x y) (append y (list x))) nil sequence))

fold-left版

(define (reverse-2 sequence)
  (fold-left (lambda (x y) (cons y x)) nil sequence))

コード

##(sicp-answer-code "ex-2.39.scm")

このサイトは、 IPA の「平成15年度オープンソフトウエア活用基盤整備事業」 の委託事業として開発されたKahuaで試験的に運用しております。

Copyright (c) 2004-2007 株式会社タイムインターメディア About Us