2014年3月18日火曜日

開発環境

プログラミングGauche(Kahuaプロジェクト (著)、 川合 史朗 (監修)、オライリージャパン)の第3部(実用的なプログラミング)、14章(入出力)、14.3(ポート)、14.3.2(文字列ポート)、練習問題(p.202)を解いてみる。

その他参考書籍

練習問題(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 コメント:

コメントを投稿