2014年3月18日火曜日

開発環境

計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の2(データによる抽象の構築)、2.2(階層データ構造と閉包性)、2.2.1(並びの表現)、リスト演算、問題 2.18.を解いてみる。

その他参考書籍

問題 2.18.

コード(BBEdit, Emacs)

sample.scm

#!/usr/bin/env gosh
;; -*- coding: utf-8 -*-

(define (reverse items)
  (define (iter a result)
    (if (null? a)
        result
        (iter (cdr a)
              (cons (car a)
                    result))))
  (iter items '()))

(for-each print
          (map reverse
               (list (list 1 4 9 16 25)
                     (list))))

入出力結果(Terminal(gosh), REPL(Read, Eval, Print, Loop))

$ ./sample.scm
(25 16 9 4 1)
()
$

0 コメント:

コメントを投稿