gaucheノート

REPLの起動

$ gosh
gosh>

REPLの終了

gosh> (exit)


gosh> (define list (list "a" "b" "c"))
list
gosh> list
("a" "b" "c")
gosh>


gosh> (define (square n) (* n n))
square
gosh> (square 2)
4
gosh> (square 25)
625


gosh> pi
*** ERROR: unbound variable: pi
Stack Trace:
_______________________________________
gosh> (use math.const)
#
gosh> pi
3.141592653589793
gosh> (define (area_of_the_circle r) (* (* r r) pi))
area_of_the_circle
gosh> (area_of_the_circle 2)
12.566370614359172

参照したURL: http://d.hatena.ne.jp/rui314/20070115/p1


標準入力のデータをそのまま標準出力へ出力する

gosh> (define (type)
(let ((c (read-char)))
(cond ((not (eof-object? c))
(display c)
(type)))))
type
gosh> (type)

Hello[Enter]
Hello
12345[Enter]
12345
[Ctrl]+D
#
gosh>

参照したURL: http://www.geocities.jp/m_hiroi/func/abcscm07.html