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$F$D$M$K
SCM $B$O(B Aubrey Jaffer $B;a$K$h$C$F8x3+$5$l$F$$$k(B Scheme $B%$%s%?%W%j%?(B
$B$G!"
STk $B$O(B Scheme $B4X?t$+$i(B Tk $B$N%$%s%?!<%U%'%$%9$r;H$($k$h$&$K$7$?%$(B
$B%s%?%W%j%?$G!"(BErick Gallesio $B;a$K$h$C$F8x3+$5$l$F$$$^$9!#(BTk $B$r;H$C(B
$B$?%0%i%U%#%+%k$J3+H/4D6-$,IUB0$7$F$*$j!"(BWindows $B$G$bF0:n$7$^$9!#$[(B
$B$+$K$b@55,I=8=$K$h$k%Q%?!<%s%^%C%A%s%0$d%=%1%C%HDL?.!"(BC $B$G:n@.$7$?(B
$B%i%$%V%i%j$N%@%$%J%_%C%/%j%s%/$J$IB?$/$N5!G=$r$=$J$($F$$$^$9!#(B
http://kaolin.unice.fr/STk/STk.html
Bigloo $B$O(B Manuel Serrano $B;a$K$h$C$F8x3+$5$l$F$$$k(B Scheme $B%3%s%Q%$(B
$B%i$G!"(BScheme $B%=!<%9%3!<%I$r(B C $B$KJQ49$7$F%P%$%J%j$r@8@.$7$^$9!#%3%s(B
$B%Q%$%i$N>l9g!"(BScheme $B$N%a%j%C%H$,$9$Y$F5|e$G$"$j!"
$B$^$?!"=q@R$G$O(B Scheme $B$N:n $BCm(B:
1. $B7G:\$N$$$-$5$D(B: 4$B7n$NCf$4$m!"5;=QI>O@ 2. $B7G:\;~!"$\$/$O$3$3$r!V(B1970$BG/Be!W$H$7$F$^$7$?!#(B
70$BG/Be$K3+H/$5$l$?$N$O(B Scheme $B$N$[$&$G$9$M!#$9$_$^$;$s!#(B
Scheme $B$r;H$C$F$_$k(B
% ./configure
% make
% make install
(use-modules (ice-9 readline))
(activate-readline)
% guile
guile>
guile> (* (+ 2 3) 5)
25
guile> (define x 4) $B!D(B [1]
guile> (* x 2) $B!D(B [2]
8
Scheme $B$NF0:n(B
$B?^(B 1 $B!V<0$NI>2A!W(B
$B%7%s%\%k!V(B+$B!W(B
$B"M(B $B4X?t!VB-$7;;$r$9$k!W(B($B5,B'(B 3-b.) $B?tCM!V(B2$B!W(B
$B"M(B $B?tCM!V(B2$B!W(B ($B5,B'(B 3-a.) $B?tCM!V(B3$B!W(B
$B"M(B $B?tCM!V(B3$B!W(B ($B5,B'(B 3-a.)
$B%7%s%\%k!V(B*$B!W(B
$B"M(B $B4X?t!V$+$1;;$r$9$k!W(B($B5,B'(B 3-b.) $B%j%9%H!V(B(+ 2 3)$B!W(B
$B"M(B $B?tCM!V(B5$B!W(B ($B5,B'(B 3-c.) $B?tCM!V(B5$B!W(B
$B"M(B $B?tCM!V(B5$B!W(B ($B5,B'(B 3-a.)
$B4X?tDj5A$H@)8f9=B$(B
guile> (define fact
... (lambda (n) (if (= n 0) 1
... (* (fact (- n 1)) n))))
guile> (fact 5)
120
(lambda ($B%7%s%\%k(B1 $B%7%s%\%k(B2 ... $B%7%s%\%k(Bm) $B<0(B1 $B<0(B2 ... $B<0(Bn)
(define newproc (lambda (a b c) (proc1 a) (proc2 b) (proc3 c)))
newproc(a, b, c)
{
proc1(a);
proc2(b);
proc3(c);
}
(if $B<0(B1 $B<0(B2 $B<0(B3)
$B4X?t(B fact-tail $B$b(B fact $B$HF1$8$h$&$K(B
$B3,>h$r7W;;$9$k4X?t$G$9$,!"(B
$B$3$A$i$O(B fact $B$H0c$$KvHx:F5"$r;HMQ$7$F$$$^$9!#KvHx:F5"$H$O!"!V<+J,(B
$B<+?H$N8F$S=P$7$,4X?t$N:G8e$KI>2A$5$l$k!W$h$&$J:F5"8F$S=P$7$r$$$$(B
$B$^$9!#>e$NNc$G$O!"(Bfact-tail $BCf$G8F$S=P$7$F$$$k(B
$B!VFbB&$N(B fact-tail$B!W(B
$B$NJV$jCM$=$N$b$N$,!"$3$N!V30B&$N(B fact-tail $B$NJV$jCM!W$K$J$j$^$9$N(B
$B$G!"JV$jCM$r3P$($F$*$/$?$a$K%9%?%C%/$r>CHq$7$J$/$F$b$h$$$N$G$9!#(B
Scheme $B$N5,3J(B R5RS $B$K$O(B
$B!VKvHx:F5"$r;H$($P!":F5"8F$S=P$7$Ofact-tail $B$,$I$N$h$&$KF0$/$N$+9M$($F$_(B
$B$F$/$@$5$$!#(B
guile> (define fact-tail
... (lambda (n x) (if (= n 0) x
... (fact-tail (- n 1) (* n x)))))
guile> (fact-tail 5 1)
120
XML $B%Q!<%6$b$I$-$r:n$k(B
$B?^(B2 $B!V(BXML $B8@8l$NLZ9=B$!W(B
guile> (load "parsexml.scm")
guile> (define tree1 (parse-xml-file "test.xml"))
guile> tree1
(<document> (<title> "sample") (<section> "section" "1")
(<section> "section" "2" (<subsection> "subsection")))
<document>
<title> sample </title>
<section> section 1 </section>
<section> section 2
<subsection> subsection </subsection>
</section>
</document>
guile> (search-xml (lambda (t) (eq? '<subsection> (car t))) tree1)
((<subsection> "subsection"))
$B?^(B3 $B!V4X?t%*%V%8%'%/%H$rKd$a9~$`!W(B
guile> (define is-a? (lambda (tag t) (eq? tag (car t))))
guile> (search-xml
... (lambda (t1)
... (and (is-a? '<section> t1)
... (not (null? (search-xml
... (lambda (t2) (is-a? '<subsection> t2)) t1)))))
... tree1)
((<section> "section" "2" (<subsection> "subsection")))
$B%W%m%0%i%`$N@bL@(B
guile> (cons 'a '(b c))
(a b c)
$B3F
$BF|K\$G$O!"(B
$BIY;3Bg3X$NLZB<(B $B4`$5$s$N%Z!<%8(B $B$,Am9g:w0z$H$7$F$*$9$9$a$G$9!#(B
($BCm(B: STk $B$O$3$A$i$K$b%_%i!<$7$F$*$-$^$7$?!#(Bftp://tanaka-www.cs.titech.ac.jp/home/euske/STk/
$B$J$*!"(BSTk $B$O?7;3$,8&5f>e$N%7%9%F%`$r9=C[$9$k%W%i%C%H%U%)!<%`$H$7$F$b(B
$B;H$C$F$$$^$9!#>\$7$/$O(B
Kairai $B%[!<%`%Z!<%8(B
$B$r$I$&$>(B)
Last Modified: Sat Feb 18 17:25:07 EST 2006 (02/19, 07:25 JST)
Yusuke Shinyama