開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Scheme (プログラミング言語)
- Gauche (処理系)
プログラミングGauche(Kahuaプロジェクト (著)、 川合 史朗 (監修)、オライリージャパン)の第3部(実用的なプログラミング)、14章(入出力)、14.3(ポート)、14.3.2(文字列ポート)、練習問題(p.202)を解いてみる。
その他参考書籍
- Scheme手習い(Daniel P. Friedman (著), Matthias Felleisen (著), 元吉 文男 (翻訳), 横山 晶一 (翻訳), オーム社)
- 計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))
- Instructor's Manual to Accompany Structure & Interpretation of Computer Programs
練習問題(p.202)
コード(BBEdit, Emacs)
sample.scm
#!/usr/bin/env gosh
;; -*- coding: utf-8 -*-
(define (my-write-to-string o)
(call-with-output-string (lambda (out)
(write o out))))
(define (my-read-from-string s)
(call-with-input-string s read))
入出力結果(Terminal(gosh), REPL(Read, Eval, Print, Loop))
gosh> #t gosh> (my-write-to-string 123) "123" gosh> (my-write-to-string '(a b c)) "(a b c)" gosh> (write-to-string 123) "123" gosh> (write-to-string '(a b c)) "(a b c)" gosh> (my-read-from-string "(1 2 3)") (1 2 3) gosh> (my-read-from-string "\"foo\"") "foo" gosh> (read-from-string "(1 2 3)") (1 2 3) gosh> (read-from-string "\"foo\"") "foo" gosh>
0 コメント:
コメントを投稿