Land of Lisp
(オライリージャパン)
M.D. Conrad Barski (著) 川合 史朗 (翻訳)
原書: Land of LISP
Learn to Program in Lisp, One Game at a Time!
開発環境
- OS X Yosemite - Apple (OS)
- Emacs(Text Editor)
- Scheme (プログラミング言語)
- kscheme, Gauche, MIT/GNU Scheme, GNU Guile (処理系)
Land of Lisp (M.D. Conrad Barski (著)、川合 史朗 (翻訳)、オライリージャパン)の7章(単純なリストの先へ)、7.2(複雑なデータを扱うには)を Scheme で取り組んでみる。
7.2(複雑なデータを扱うには)
コード(Emacs)
(begin
(define print (lambda (x) (display x) (newline)))
(define *house* (quote ((walls (mortar (cement)
(water)
(sand)))
(windows (glass)
(frame)
(curtains))
(roof (shingles)
(chimney)))))
(print *house*)
(define *wizard-nodes*
(quote ((living-room (You are in the living-room. There is a wizard is
snoring loudly on the couch.))
(garden (You are in a beatiful garden. There is a well in front of
you.))
(attic (You are in the attic. There is a giant welding torch in
the corner.)))))
(print *wizard-nodes*)
(define *wizard-edges* (quote ((living-room (garden west door)
(attic upstairs ladder))
(garden (living-room east door))
(attic (living-room downstairs ladder)))))
(print *wizard-edges*)
(quote done))
入出力結果(Terminal(kscheme), REPL(Read, Eval, Print, Loop))
$ kscheme sample2.scm ((walls (mortar (cement) (water) (sand))) (windows (glass) (frame) (curtains)) (roof (shingles) (chimney))) ((living-room (You are in the living-room. There is a wizard is snoring loudly on the couch.)) (garden (You are in a beatiful garden. There is a well in front of you.)) (attic (You are in the attic. There is a giant welding torch in the corner.))) ((living-room (garden west door) (attic upstairs ladder)) (garden (living-room east door)) (attic (living-room downstairs ladder))) done $
0 コメント:
コメントを投稿