Annotation of OpenXM/src/asir-doc/parts/asir.texi, Revision 1.2
1.1 noro 1: @node $B%f!<%68@8l(B Asir,,, Top
2: @chapter $B%f!<%68@8l(B Asir
3:
4: @noindent
5: @b{Asir} $B$NAH$_9~$_H!?t$O(B, $B0x?tJ,2r(B, GCD $B$J$I$N7W;;$r9T$&$b$N(B, $B%U%!(B
6: $B%$%kF~=PNO$r9T$&$b$N(B, $B$"$k$$$O?t<0$N0lIt$r<h$j=P$9$b$N$J$I$5$^$6$^$J$b$N(B
7: $B$,MQ0U$5$l$F$$$k$,(B, $B%f!<%6$,<B:]$K9T$$$?$$$3$H$r<B9T$5$;$k$?$a$K$O0l(B
8: $BHL$K$O%f!<%68@8l$K$h$k%W%m%0%i%`$r=q$/I,MW$,$"$k(B. $B%f!<%68@8l$b(B
9: @b{Asir} $B$H8F$P$l$k(B. $B0J2<$G$O(B, $B%f!<%68@8l$NJ8K!5,B'$*$h$S<B:]$N%f!<(B
10: $B%68@8l%W%m%0%i%`$rNc$H$7$?%W%m%0%i%`$N=q$-J}$K$D$$$F=R$Y$k(B.
11:
12: @menu
13: * $BJ8K!(B (C $B8@8l$H$N0c$$(B)::
14: * $B%f!<%6Dj5AH!?t$N=q$-J}(B::
15: @end menu
16:
17:
18: @node $BJ8K!(B (C $B8@8l$H$N0c$$(B),,, $B%f!<%68@8l(B Asir
19: @section $BJ8K!(B (C $B8@8l$H$N0c$$(B)
20:
21: @noindent
22: @b{Asir} $B$NJ8K!$O(B C $B8@8l$K=`5r$7$F$$$k(B.
23: $B$*$b$JAj0cE@$O<!$NDL$j$G$"$k(B. $B0J2<$G(B, $BJQ?t$H$O(B @b{Asir} $B$K$*$1$k(B
24: $B%W%m%0%i%`MQ$NJQ?t(B, $B$9$J$o$ABgJ8;z$G;O$^$kJ8;zNs$r0UL#$9$k$3$H$H$9$k(B.
25:
26: @itemize @bullet
27: @item
28: $BJQ?t$N7?$,$J$$(B.
29:
30: $B4{$K@bL@$7$?$H$*$j(B, @b{Asir} $B$G07$o$l$kBP>]<+?H$OA4$F2?$i$+$N7?(B
31: $B$r;}$C$F$$$k(B. $B$7$+$7(B, $B%W%m%0%i%`JQ?t<+BN$O(B, $B$I$N$h$&$JBP>]$G$b(B
32: $BBeF~$G$-$k$H$$$&0UL#$G7?$,$J$$$N$G$"$k(B.
33:
34: @example
35: [0] A = 1;
36: 1
37: [1] type(A);
38: 1
39: [2] A = [1,2,3];
40: [1,2,3]
41: [3] type(A);
42: 4
43: @end example
44:
45: @item
46: $BH!?tFb$NJQ?t$O(B, $B%G%U%)%k%H$G$O2>0z?t$r$3$a$F$9$Y$F6I=jJQ?t(B.
47: $B$?$@$7(B, @code{extern} $B@k8@$5$l$?JQ?t$O(B, $B%H%C%W%l%Y%k$K$*$1$kBg0hJQ?t$H$J$k(B.
48:
49: $B$9$J$o$A(B, $BJQ?t$N%9%3!<%W$OBg0hJQ?t$H6I=jJQ?t$N(B 2 $B<oN`$KC1=c2=$5$l$F$$$k(B.
50: $B%H%C%W%l%Y%k(B, $B$9$J$o$A%W%m%s%W%H$KBP$7$FF~NO$5$l$?JQ?t$OA4$FBg0hJQ?t(B
51: $B$H$7$FEPO?$5$l$k(B. $B$^$?H!?tFb$G$O<!$N$$$:$l$+$H$J$k(B.
52:
53: @enumerate
54: @item
55: $BH!?t$,Dj5A$5$l$k%U%!%$%k$K$*$$$F(B, $B$=$NH!?tDj5A0JA0$K(B, $B$"$k(B
56: $BJQ?t$,(B @code{extern} $B@k8@$5$l$F$$$k>l9g(B, $BH!?tFb$N$=$NJQ?t$bBg0hJQ?t(B
57: $B$H$7$F07$o$l$k(B.
58:
59: @item
60: @code{extern} $B@k8@$5$l$F$$$J$$JQ?t$O$=$NH!?t$K6I=jE*$H$J$k(B.
61: @end enumerate
62:
63: @example
64: % cat afo
65: def afo() @{ return A;@}
66: extern A$
67: def bfo() @{ return A;@}
68: end$
69: % asir
70: [0] load("afo")$
71: [5] A = 1;
72: 1
73: [6] afo();
74: 0
75: [7] bfo();
76: 1
77: @end example
78:
79: @item
80: $B%W%m%0%i%`JQ?t$OBgJ8;z$G;O$^$j(B, $BITDj85(B, $BH!?t$O>.J8;z$G;O$^$k(B.
81:
82: $B$3$NE@$O(B, $B4{B8$N?t<0=hM}%7%9%F%`$N$[$H$s$I$H0[$J$kE@$G$"$k(B. @b{Asir}
83: $B$,$3$N;EMM$r:NMQ$7$?$N$O(B, $B%f!<%6$,ITDj85$N$D$b$j$G;HMQ$7$?JQ?t$K(B
84: $B$J$s$i$+$NCM$,BeF~$5$l$F$$$?>l9g$K:.Mp$r>7$/(B, $B$H$$$&(B, $B4{B8$N(B
85: $B%7%9%F%`$K$"$j$,$A$J>u67$rHr$1$k$?$a$G$"$k(B.
86:
87: @item
88: @code{switch} $BJ8(B, @code{goto} $B$,$J$$(B.
89:
90: @code{goto} $B$,$J$$$?$a(B, $BB?=E%k!<%W$r0lEY$KH4$1$k$N$,$d$dJ#;($K$J$k>l9g$,$"$k(B.
91:
92: @item
93: $B%3%s%^<0$O(B, @code{for (A;B;C)} $B$^$?$O(B, @code{while(A)} $B$N(B @code{A}, @code{B}, @code{C} $B$K$N$_;H$&$3$H$,$G$-$k(B.
94:
95: $B$3$l$O(B, $B%j%9%H$r@5<0$J%*%V%8%'%/%H$H$7$F2C$($?$3$H$K$h$k(B.
96:
97: @end itemize
98:
99: @noindent
100: $B0J>e$O@)8B$G$"$k$,(B, $B3HD%$H$7$F$O<!$NE@$,5s$2$i$l$k(B.
101:
102: @itemize @bullet
103: @item
104: $BM-M}<0$KBP$9$k7W;;$r(B, $BDL>o$N(B C $B$K$*$1$k7W;;$HF1MM$K$G$-$k(B.
105:
106: @item
107: $B%j%9%H$,07$($k(B.
108:
109: $B9=B$BN$rMQ$$$k$^$G$b$J$$MWAG$N=89gBN$r(B, $B%j%9%H$GI=$9$3$H$,$G$-(B,
110: C $B$GD>@\=q$/>l9g$KHf3S$7$F%W%m%0%i%`$,C;$/(B, $BFI$_$d$9$/=q$1$k(B.
1.2 ! noro 111:
! 112: @item
! 113: $B%f!<%6Dj5AH!?t$K$*$1$k%*%W%7%g%s;XDj(B.
! 114:
! 115: $B$3$l$K4X$7$F$O(B, @xref{$B%*%W%7%g%s;XDj(B}.
1.1 noro 116: @end itemize
117:
118: @node $B%f!<%6Dj5AH!?t$N=q$-J}(B,,, $B%f!<%68@8l(B Asir
119: @section $B%f!<%6Dj5AH!?t$N=q$-J}(B
120:
121: @menu
122: * $B%f!<%6Dj5AH!?t(B::
123: * $BJQ?t$*$h$SITDj85(B::
124: * $B0z?t(B::
125: * $B%3%a%s%H(B::
126: * $BJ8(B::
127: * return $BJ8(B::
128: * if $BJ8(B::
129: * $B%k!<%W(B break return continue::
130: * $B$5$^$6$^$J<0(B::
131: * $B%W%j%W%m%;%C%5(B::
1.2 ! noro 132: * $B%*%W%7%g%s;XDj(B::
1.1 noro 133: @end menu
134:
135: @node $B%f!<%6Dj5AH!?t(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
136: @subsection $B%f!<%6Dj5AH!?t(B
137:
138: @noindent
139: $B%f!<%6$K$h$kH!?t$NDj5A$O(B @samp{def} $BJ8$G9T$&(B. $BJ8K!%(%i!<$OFI$_9~$_;~$K(B
140: $B$"$kDxEY%A%'%C%/$5$l(B, $B$*$*$h$=$N>l=j$,I=<($5$l$k(B.
141: $B4{$K(B($B0z?t$N8D?t$K4X78$J$/(B)$BF1L>$NH!?t$,Dj5A$5$l$F$$$k>l9g$K$O(B,
142: $B$=$NH!?t$O:FDj5A$5$l$k(B. @code{ctrl()} $BH!?t$K$h$j(B @code{verbose} $B%U%i%0(B
143: $B$,(B on $B$K$J$C$F$$$k>l9g(B,
144:
145: @example
146: afo() redefined.
147: @end example
148:
149: @noindent
150: $B$H$$$&%a%C%;!<%8$,I=<($5$l$k(B. $B$"$kH!?t$NDj5A$K$*$$$F(B, $B$^$@L$Dj5A$NH!?t(B
151: $B$r8F$S=P$7$F$$$F$b(B, $BDj5A;~$K$O%(%i!<$K$J$i$J$$(B. $B<B9T;~$KL$Dj5A$NH!?t(B
152: $B$r8F$S=P$=$&$H$7$?>l9g$K%(%i!<$H$J$k(B.
153:
154: @example
155: @tex
156: /* $X!$ */
157: @end tex
158:
159: def f(X) @{
160: if ( !X )
161: return 1;
162: else
163: return X * f(X-1);
164: @}
165:
166: @tex
167: /* ${_i}C_j ( 0 \le i \le N, 0 \le j \le i )$ */
168: @end tex
169:
170: def c(N)
171: @{
172: A = newvect(N+1); A[0] = B = newvect(1); B[0] = 1;
173: for ( K = 1; K <= N; K++ ) @{
174: A[K] = B = newvect(K+1); B[0] = B[K] = 1;
175: for ( P = A[K-1], J = 1; J < K; J++ )
176: B[J] = P[J-1]+P[J];
177: @}
178: return A;
179: @}
180: @end example
181:
182: @noindent
183: 2 $B$DL\$NNc$G$O(B, $BD9$5(B @code{N+1} $B$N%Y%/%H%k(B (@code{A}$B$H$9$k(B) $B$,JV$5$l$k(B.
184: @code{A[I]} $B$OD9$5(B @code{I+1} $B$NG[Ns$G$"$j(B, $B$=$N$=$l$>$l$NMWAG$,(B
185: @iftex
186: @tex
187: ${_I}C_J$
188: @end tex
189: @end iftex
190: @ifinfo
191: ICJ
192: @end ifinfo
193: $B$rMWAG$H$9$kG[Ns$G$"$k(B.
194:
195: @noindent
196: $B0J2<$G$O(B, C $B$K$h$k%W%m%0%i%_%s%0$N7P83$,$J$$?M$N$?$a$K(B, @b{Asir} $B8@8l(B
197: $B$K$h$k%W%m%0%i%`$N=q$-J}$r2r@b$9$k(B.
198:
199: @node $BJQ?t$*$h$SITDj85(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
200: @subsection $BJQ?t$*$h$SITDj85(B
201:
202: @noindent
203: $B4{$K=R$Y$?DL$j(B, @b{Asir} $B$K$*$$$F$O%W%m%0%i%`JQ?t$HITDj85$rL@3N$K(B
204: $B6hJL$7$F$$$k(B.
205:
206: @table @b
207: @item $BJQ?t(B
208: $BBgJ8;z$G;O$^$j(B, $B%"%k%U%!%Y%C%H(B, $B?t;z(B, @samp{_} $B$+$i$J$kJ8;zNs(B
209:
210: $BJQ?t$"$k$$$O%W%m%0%i%`JQ?t$H$O(B, @b{Asir} $B$N$5$^$6$^$J7?$NFbIt7A<0$r(B
211: $B3JG<$9$k$?$a$NH"$G$"$j(B, $B3JG<$5$l$?FbIt7A<0$,(B, $B$3$NJQ?t$NCM$G$"$k(B. $BJQ(B
212: $B?t$,<0$NMWAG$H$7$FI>2A$5$l$k;~$O(B, $B$=$3$K<}$a$i$l$?CM$KCV$-49$($i$l$k(B.
213: $B$9$J$o$A(B, $BFbIt7A<0$NCf$K$O%W%m%0%i%`JQ?t$O8=$l$J$$(B. $BJQ?t$OA4$F(B 0 $B$G(B
214: $B=i4|2=$5$l$F$$$k(B.
215:
216: @example
217: [0] X^2+X+1;
218: 1
219: [1] X=2;
220: 2
221: [2] X^2+X+1;
222: 7
223: @end example
224:
225: @item $BITDj85(B
226: $B>.J8;z$G;O$^$j(B, $B%"%k%U%!%Y%C%H(B, $B?t;z(B, @samp{_} $B$+$i$J$kJ8;zNs(B
227:
228: $BITDj85$H$O(B, $BB?9`<04D$r9=@.$9$k:]$KE:2C$5$l$kJQ?t$r$$$&(B. @b{Asir} $B$K(B
229: $B$*$$$F$O(B, $BITDj85$OCM$r$b$?$J$$D61[E*$J85$G$"$j(B, $BITDj85$X$NCM$NBeF~$O(B
230: $B5v$5$l$J$$(B.
231:
232: @example
233: [3] X=x;
234: x
235: [4] X^2+X+1;
236: x^2+x+1
237: @end example
238: @end table
239:
240: @node $B0z?t(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
241: @subsection $B0z?t(B
242:
243: @example
244: def sum(N) @{
245: for ( I = 1, S = 0; I <= N; I++ )
246: S += I;
247: return S;
248: @}
249: @end example
250:
251: @noindent
252: $B$3$l$O(B, 1 $B$+$i(B @code{N} $B$^$G$N<+A3?t$NOB$r5a$a$kH!?t(B @code{sum()} $B$N(B
253: $BDj5A$G$"$k(B. $B$3$NNc$K$*$1$k(B @code{sum(N)} $B$N(B @code{N} $B$,0z?t$G$"$k(B.
254: $B$3$NNc$O(B, 1 $B0z?tH!?t$NNc$G$"$k$,(B, $B0lHL$K0z?t$N8D?t$OG$0U$G$"$j(B,
255: $BI,MW$J$@$1$N8D?t$r(B @samp{,} $B$G6h@Z$C$F;XDj$9$k$3$H$,$G$-$k(B. $B0z?t$O(B
256: $BCM$,EO$5$l$k(B. $B$9$J$o$A(B, $B0z?t$r<u$1$H$C$?B&$,(B, $B$=$N0z?t$NCM$rJQ99$7$F(B
257: $B$b(B, $BEO$7$?B&$NJQ?t$OJQ2=$7$J$$(B. $B$?$@$7(B, $BNc30$,$"$k(B. $B$=$l$O(B, $B%Y%/%H%k(B,
258: $B9TNs$r0z?t$KEO$7$?>l9g$G$"$k(B. $B$3$N>l9g$b(B, $BEO$5$l$?JQ?t$=$N$b$N$r=q$-(B
259: $BBX$($k$3$H$O(B, $B$=$NH!?t$K6I=jE*$JA`:n$G$"$k$,(B, $BMWAG$r=q$-49$($?>l9g(B,
260: $B$=$l$O(B, $B8F$S=P$7B&$N%Y%/%H%k(B, $B9TNs$NMWAG$r=q$-49$($k$3$H$K$J$k(B.
261:
262: @example
263: def clear_vector(M) @{
264: /* M is expected to be a vector */
265: L = size(M)[0];
266: for ( I = 0; I < L; I++ )
267: M[I] = 0;
268: @}
269: @end example
270:
271: @noindent
272: $B$3$NH!?t$O(B, $B0z?t$N%Y%/%H%k$r(B 0 $B%Y%/%H%k$K=i4|2=$9$k$?$a$NH!?t$G$"$k(B.
273: $B$^$?(B, $B%Y%/%H%k$r0z?t$KEO$9$3$H$K$h$j(B, $BJ#?t$N7k2L$r0z?t$N%Y%/%H%k$K(B
274: $B<}G<$7$FJV$9$3$H$,$G$-$k(B. $B<B:]$K$O(B, $B$3$N$h$&$J>l9g$K$O(B, $B7k2L$r%j%9%H(B
275: $B$K$7$FJV$9$3$H$b$G$-$k(B. $B>u67$K1~$8$F;H$$$o$1$9$k$3$H$,K>$^$7$$(B.
276:
277: @node $B%3%a%s%H(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
278: @subsection $B%3%a%s%H(B
279:
280: @noindent
281: C $B$HF1MM(B @samp{/*} $B$H(B @samp{*/} $B$G0O$^$l$?ItJ,$O%3%a%s%H$H$7$F07$o$l$k(B.
282:
283: @example
284: /*
285: * This is a comment.
286: */
287:
288: def afo(X) @{
289: @end example
290:
291: @noindent
292: $B%3%a%s%H$OJ#?t9T$KEO$C$F$b9=$o$J$$$,(B, $BF~$l;R$K$9$k$3$H$O$G$-$J$$(B.
293: @samp{/*} $B$,$$$/$D$"$C$F$b:G=i$N$b$N$N$_$,M-8z$H$J$j(B, $B:G=i$K8=$l$?(B
294: @samp{*/} $B$G%3%a%s%H$O=*N;$7$?$H8+$J$5$l$k(B. $B%W%m%0%i%`$J$I$G(B, $B%3%a%s%H(B
295: $B$r4^$`2DG=@-$,$"$kItJ,$r%3%a%s%H%"%&%H$7$?>l9g$K$O(B, @code{#if 0},
296: @code{#endif}$B$r;H$($P$h$$(B. (@xref{$B%W%j%W%m%;%C%5(B})
297:
298: @example
299: #if 0
300: def bfo(X) @{
301: /* empty */
302: @}
303: #endif
304: @end example
305:
306: @node $BJ8(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
307: @subsection $BJ8(B
308:
309: @noindent
310: @b{Asir} $B$N%f!<%6H!?t$O(B,
311:
312: @example
313: def $BL>A0(B($B0z?t(B,$B0z?t(B,...,$B0z?t(B) @{
314: $BJ8(B
315: $BJ8(B
316: ...
317: $BJ8(B
318: @}
319: @end example
320:
321: @noindent
322: $B$H$$$&7A$GDj5A$5$l$k(B. $B$3$N$h$&$K(B, $BJ8$OH!?t$N4pK\E*9=@.MWAG$G$"$j(B, $B%W%m(B
323: $B%0%i%`$r=q$/$?$a$K$O(B, $BJ8$,$I$N$h$&$J$b$N$G$"$k$+CN$i$J$1$l$P$J$i$J$$(B.
324: $B:G$bC1=c$JJ8$H$7$F(B, $BC1J8$,$"$k(B. $B$3$l$O(B,
325:
326: @example
327: S = sum(N);
328: @end example
329:
330: @noindent
331: $B$N$h$&$K(B, $B<0$K=*C<5-9f(B (@samp{;} $B$^$?$O(B @samp{$}) $B$r$D$1$?$b$N$G$"$k(B.
332: $B$3$NC1J85Z$SN`;w$N(B @code{return} $BJ8(B, @code{break} $BJ8$J$I$,J8$N:G>.9=@.(B
333: $BC10L$H$J$k(B. @code{if} $BJ8$d(B @code{for} $BJ8$NDj5A(B (@xref{$BJ8K!$N>\:Y(B}) $B$r8+$l(B
334: $B$P$o$+$kDL$j(B, $B$=$l$i$NK\BN$O(B, $BC1$J$k0l$D$NJ8$H$7$FDj5A$5$l$F$$$k(B. $BDL>o(B
335: $B$O(B, $BK\BN$K$OJ#?t$NJ8$,=q$1$k$3$H$,I,MW$H$J$k(B. $B$3$N$h$&$J>l9g(B,
336: @samp{@{} $B$H(B @samp{@}} $B$GJ8$NJB$S$r3g$C$F(B, $B0l$D$NJ8$H$7$F07$&$3$H$,$G(B
337: $B$-$k(B. $B$3$l$rJ#J8$H8F$V(B.
338:
339: @example
340: if ( I == 0 ) @{
341: J = 1;
342: K = 2;
343: L = 3;
344: @}
345: @end example
346:
347: @noindent
348: @samp{@}} $B$N8e$m$K$O=*C<5-9f$OI,MW$J$$(B. $B$J$<$J$i(B, @samp{@{} $BJ8JB$S(B
349: @samp{@}}$B$,4{$KJ8$H$J$C$F$$$F(B, @code{if} $BJ8$NMW@A$rK~$?$7$F$$$k$+$i$G(B
350: $B$"$k(B.
351:
352: @node return $BJ8(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
353: @subsection @code{return} $BJ8(B
354:
355: @noindent
356: @code{return} $BJ8$O(B,
357:
358: @example
359: return $B<0(B;
360:
361: return;
362: @end example
363:
364: @noindent
365: $B$N(B 2 $B$D$N7A<0$,$"$k(B. $B$$$:$l$bH!?t$+$iH4$1$k$?$a$NJ8$G$"$k(B. $BA0<T$O(B
366: $BH!?t$NCM$H$7$F(B $B<0(B $B$rJV$9(B. $B8e<T$G$O(B, $BH!?t$NCM$H$7$F2?$,JV$5$l$k$+(B
367: $B$O$o$+$i$J$$(B.
368:
369: @node if $BJ8(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
370: @subsection @code{if} $BJ8(B
371:
372: @noindent
373: @code{if} $BJ8$K$O(B
374:
375: @example
376: if ( $B<0(B ) if ( $B<0(B )
377: $BJ8(B $B5Z$S(B $BJ8(B
378: else
379: $BJ8(B
380: @end example
381:
382: @noindent
383: $B$N(B 2 $B<oN`$,$"$k(B. $B$3$l$i$NF0:n$OL@$i$+$G$"$k$,(B, $BJ8$N0LCV$K(B @code{if} $BJ8(B
384: $B$,Mh$?>l9g$KCm0U$rMW$9$k(B. $B<!$NNc$r9M$($F$_$h$&(B.
385:
386: @example
387: if ( $B<0(B )
388: if ( $B<0(B ) $BJ8(B
389: else
390: $BJ8(B
391: @end example
392:
393: @noindent
394: $B$3$N>l9g(B, $B;z2<$2$+$i$O(B, @code{else} $B0J2<$O(B, $B:G=i$N(B @code{if} $B$KBP1~$9$k(B
395: $B$h$&$K8+$($k$,(B, $B%Q!<%6$O(B, $B<+F0E*$K(B 2 $BHVL\$N(B @code{if} $B$KBP1~$9$k$HH=CG$9$k(B.
396: $B$9$J$o$A(B, 2 $B<oN`$N(B @code{if} $BJ8$r5v$7$?$?$a$K(B, $BJ8K!$K[#Kf@-$,8=$l(B, $B$=$l$r(B
397: $B2r>C$9$k$?$a$K(B, @code{else} $B0J2<$O(B, $B:G$b6a$$(B @code{if} $B$KBP1~$9$k$H(B
398: $B$$$&5,B'$,E,MQ$5$l$k$N$G$"$k(B. $B=>$C$F(B, $B$3$NNc$O(B,
399:
400: @example
401: if ( $B<0(B ) @{
402: if ( $B<0(B ) $BJ8(B else $BJ8(B
403: @}
404: @end example
405:
406: @noindent
407: $B$H$$$&0UL#$H$J$k(B. $B;z2<$2$KBP1~$5$;$k$?$a$K$O(B,
408:
409: @example
410: if ( $B<0(B ) @{
411: if ( $B<0(B ) $BJ8(B
412: @} else
413: $BJ8(B
414: @end example
415:
416: @noindent
417: $B$H$7$J$1$l$P$J$i$J$$(B.
418:
419: @node $B%k!<%W(B break return continue,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
420: @subsection $B%k!<%W(B, @code{break}, @code{return}, @code{continue}
421:
422: @noindent
423: $B%k!<%W$r9=@.$9$kJ8$O(B, @code{while} $BJ8(B, @code{for} $BJ8(B, @code{do} $BJ8(B
424: $B$N(B 3 $B<oN`$,$"$k(B.
425:
426: @itemize @bullet
427: @item
428: @code{while} $BJ8(B
429:
430: $B7A<0$O(B,
431:
432: @example
433: while ( $B<0(B ) $BJ8(B
434: @end example
435:
436: @noindent
437: $B$G(B, $B$3$l$O(B, $B<0(B $B$rI>2A$7$F(B, $B$=$NCM$,(B 0 $B$G$J$$8B$j(B $BJ8(B $B$r<B9T$9$k$H$$$&(B
438: $B0UL#$H$J$k(B. $B$?$H$($P(B $B<0(B $B$,(B 1 $B$J$i$P(B, $BC1=c$JL58B%k!<%W$H$J$k(B.
439:
440: @item
441: @code{for} $BJ8(B
442:
443: $B7A<0$O(B,
444:
445: @example
446: for ( $B<0JB$S(B-1; $B<0(B; $B<0JB$S(B-2 ) $BJ8(B
447: @end example
448:
449: $B$G(B, $B$3$l$O(B
450:
451: @example
452: $B<0JB$S(B-1 ($B$rC1J8JB$S$K$7$?$b$N(B)
453: while ( $B<0(B ) @{
454: $BJ8(B
455: $B<0JB$S(B-2 ($B$rC1J8JB$S$K$7$?$b$N(B)
456: @}
457: @end example
458:
459: $B$HEy2A$G$"$k(B.
460:
461: @item
462: @code{do} $BJ8(B
463:
464: @example
465: do @{
466: $BJ8(B
467: @} while ( $B<0(B )
468: @end example
469:
470: $B$O(B, $B@h$K(B $BJ8$r<B9T$7$F$+$i>r7o<0$K$h$kH=Dj$r9T$&=j$,(B @code{while} $BJ8(B
471: $B$H0[$J$C$F$$$k(B.
472: @end itemize
473:
474: @noindent
475: $B%k!<%W$rH4$1=P$9<jCJ$H$7$F(B,
476: @code{break} $BJ85Z$S(B @code{return} $BJ8$,$"$k(B. $B$^$?(B, $B%k!<%W$N@)8f$r(B
477: $B$"$k0LCV$K0\$9<jCJ$H$7$F(B @code{continue} $BJ8$,$"$k(B.
478:
479: @itemize @bullet
480:
481: @item
482: @code{break}
483:
484: @code{break} $BJ8$O(B, $B$=$l$r0O$`%k!<%W$r0l$D$@$1H4$1$k(B.
485:
486: @item
487: @code{return}
488:
489: @code{return} $BJ8$O(B, $B0lHL$KH!?t$+$iH4$1$k$?$a$NJ8$G$"$j(B,
490: $B%k!<%W$NCf$+$i$G$bM-8z$G$"$k(B.
491:
492: @item
493: @code{continue}
494:
495: @code{continue} $BJ8$O(B, $B%k!<%W$NK\BN$NJ8$NKvC<$K@)8f$r0\$9(B.
496: $BNc$($P(B @code{for} $BJ8$G$O(B, $B:G8e$N<0JB$S$N<B9T$r9T$$(B, @code{while}
497: $BJ8$G$O>r7o<0$NH=Dj$K0\$k(B.
498: @end itemize
499:
500: @node $B$5$^$6$^$J<0(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
501: @subsection $B$5$^$6$^$J<0(B
502:
503: @noindent
504: $B<g$J<0$N9=@.MWAG$H$7$F$O(B, $B<!$N$h$&$J$b$N$,$"$k(B.
505:
506: @itemize @bullet
507: @item
508: $B2C8:>h=|(B, $BQQ(B
509:
510: $BQQ$O(B, @samp{^} $B$K$h$jI=$9(B. $B=|;;(B @samp{/} $B$O(B, $BBN$H$7$F$N1i;;$KMQ$$$k(B.
511: $BNc$($P(B, @code{2/3} $B$OM-M}?t$N(B @code{2/3} $B$rI=$9(B.
512: $B@0?t=|;;(B, $BB?9`<0=|;;(B ($B>jM>$r4^$`1i;;(B) $B$K$OJLESAH$_9~$_H!?t$,MQ0U$5$l$F$$$k(B.
513:
514: @example
515: x+1 A^2*B*afo X/3
516: @end example
517:
518: @item
519: $B%$%s%G%C%/%9$D$-$NJQ?t(B
520:
521: $B%Y%/%H%k(B, $B9TNs(B, $B%j%9%H$NMWAG$O%$%s%G%C%/%9$rMQ$$$k$3$H$K$h$j<h$j=P$;$k(B.
522: $B%$%s%G%C%/%9$O(B 0 $B$+$i;O$^$k$3$H$KCm0U$9$k(B. $B<h$j=P$7$?MWAG$,%Y%/%H%k(B,
523: $B9TNs(B, $B%j%9%H$J$i(B, $B$5$i$K%$%s%G%C%/%9$r$D$1$k$3$H$bM-8z$G$"$k(B.
524:
525: @example
526: V[0] M[1][2]
527: @end example
528:
529: @item
530: $BHf3S1i;;(B
531:
532: $BEy$7$$(B (@samp{==}), $BEy$7$/$J$$(B (@samp{!=}), $BBg>.(B (@samp{>}, @samp{<},
533: @samp{>=}, @samp{<=}) $B$N(B 2 $B9`1i;;$,$"$k(B. $B??$J$i$PM-M}?t$N(B 1, $B56$J$i$P(B
534: 0 $B$rCM$K;}$D(B.
535:
536: @item
537: $BO@M}<0(B
538:
539: $BO@M}@Q(B (@samp{&&}), $BO@M}OB(B (@samp{||}) $B$N(B 2 $B9`1i;;$H(B, $BH]Dj(B (@samp{!})
540: $B$,MQ0U$5$l$F$$$k(B. $BCM$O$d$O$j(B 1, 0 $B$G$"$k(B.
541:
542: @item
543: $BBeF~(B
544:
545: $BDL>o$NBeF~$O(B @samp{=} $B$G9T$&(B. $B$3$N$[$+(B, $B;;=Q1i;;;R$HAH$_9g$o$;$F(B
546: $BFC<l$JBeF~$r9T$&$3$H$b$G$-$k(B.
547: (@samp{+=}, @samp{-=}, @samp{*=}, @samp{/=}, @samp{^=})
548:
549: @example
550: A = 2 A *= 3 ($B$3$l$O(B A = A*3 $B$HF1$8(B; $B$=$NB>$N1i;;;R$bF1MM(B)
551: @end example
552: @item
553: $BH!?t8F$S=P$7(B
554:
555: $BH!?t8F$S=P$7$b<0$N0l<o$G$"$k(B.
556:
557: @item
558: @samp{++}, @samp{--}
559:
560: $B$3$l$i$O(B, $BJQ?t$NA08e$K$D$$$F(B, $B$=$l$>$l<!$N$h$&$JA`:n(B, $BCM$rI=$9(B.
561:
562: @example
563: A++ $BCM$O85$N(B A $B$NCM(B, A = A+1
564: A-- $BCM$O85$N(B A $B$NCM(B, A = A-1
565: ++A A = A+1, $BCM$OJQ2=8e$NCM(B
566: --A A = A-1, $BCM$OJQ2=8e$NCM(B
567: @end example
568:
569: @end itemize
570:
571: @node $B%W%j%W%m%;%C%5(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
572: @subsection $B%W%j%W%m%;%C%5(B
573:
574: @noindent
575: @b{Asir} $B$N%f!<%68@8l$O(B C $B8@8l$rLO$7$?$b$N$G$"$k(B. C $B$NFCD'$H$7$F(B,
576: $B%W%j%W%m%;%C%5(B @code{cpp} $B$K$h$k%^%/%mE83+(B, $B%U%!%$%k$N%$%s%/%k!<%I(B
577: $B$,$"$k$,(B, @b{Asir} $B$K$*$$$F$b%f!<%68@8l%U%!%$%k$NFI$_9~$_$N:](B
578: @code{cpp} $B$rDL$7$F$+$iFI$_9~$`$3$H$H$7$?(B. $B$3$l$K$h$j%f!<%68@8l(B
579: $B%U%!%$%kCf$G(B @code{#include}, @code{#define}, @code{#if} $B$J$I$,;H$($k(B.
580:
581: @itemize @bullet
582: @item
583: @code{#include}
584:
585: @code{cpp} $B$KFC$K0z?t$rEO$5$J$$$?$a(B, $B%$%s%/%k!<%I%U%!%$%k$O(B,
586: @code{#include} $B$,=q$+$l$F$$$k%U%!%$%k$HF1$8%G%#%l%/%H%j$G%5!<%A$5$l$k(B.
587:
588: @item
589: @code{#define}
590:
591: $B$3$l$O(B, C $B$K$*$1$k$N$HA4$/F1MM$KMQ$$$k$3$H$,$G$-$k(B.
592:
593: @item
594: @code{#if}
595:
596: @code{/*}, @code{*/} $B$K$h$k%3%a%s%H$OF~$l;R$K$G$-$J$$$N$G(B, $B%W%m%0%i%`(B
597: $B$NBg$-$JItJ,$r%3%a%s%H%"%&%H$9$k:]$K(B, @code{#if 0}, @code{#endif}
598: $B$r;H$&$HJXMx$G$"$k(B.
599: @end itemize
600:
601: @noindent
602: $B<!$NNc$O(B, @samp{defs.h} $B$K$"$k%^%/%mDj5A$G$"$k(B.
603:
604: @example
605: #define ZERO 0
606: #define NUM 1
607: #define POLY 2
608: #define RAT 3
609: #define LIST 4
610: #define VECT 5
611: #define MAT 6
612: #define STR 7
613: #define N_Q 0
614: #define N_R 1
615: #define N_A 2
616: #define N_B 3
617: #define N_C 4
618: #define V_IND 0
619: #define V_UC 1
620: #define V_PF 2
621: #define V_SR 3
622: #define isnum(a) (type(a)==NUM)
623: #define ispoly(a) (type(a)==POLY)
624: #define israt(a) (type(a)==RAT)
625: #define islist(a) (type(a)==LIST)
626: #define isvect(a) (type(a)==VECT)
627: #define ismat(a) (type(a)==MAT)
628: #define isstr(a) (type(a)==STR)
629: #define FIRST(L) (car(L))
630: #define SECOND(L) (car(cdr(L)))
631: #define THIRD(L) (car(cdr(cdr(L))))
632: #define FOURTH(L) (car(cdr(cdr(cdr(L)))))
633: #define DEG(a) deg(a,var(a))
634: #define LCOEF(a) coef(a,deg(a,var(a)))
635: #define LTERM(a) coef(a,deg(a,var(a)))*var(a)^deg(a,var(a))
636: #define TT(a) car(car(a))
637: #define TS(a) car(cdr(car(a)))
638: #define MAX(a,b) ((a)>(b)?(a):(b))
639: @end example
1.2 ! noro 640:
! 641:
! 642: @node $B%*%W%7%g%s;XDj(B,,, $B%f!<%6Dj5AH!?t$N=q$-J}(B
! 643: @subsection $B%*%W%7%g%s;XDj(B
! 644:
! 645: $B%f!<%6Dj5A4X?t$,(B @var{N} $BJQ?t$G@k8@$5$l$?>l9g(B, $B$=$N4X?t$O(B, @var{N}
! 646: $BJQ?t$G$N8F$S=P$7$N$_$,5v$5$l$k(B.
! 647:
! 648: @example
! 649: [0] def factor(A) @{ return fctr(A); @}
! 650: [1] factor(x^5-1,3);
! 651: evalf : argument mismatch in factor()
! 652: return to toplevel
! 653: @end example
! 654:
! 655: $BITDj8D0z?t$N4X?t$r%f!<%68@8l$G5-=R$7$?$$>l9g(B, $B%j%9%H(B, $BG[Ns$rMQ$$$k$3$H$G(B
! 656: $B2DG=$H$J$k$,(B, $B<!$N$h$&$J$h$jJ,$+$j$d$9$$J}K!$b2DG=$G$"$k(B.
! 657:
! 658: @example
! 659: % cat factor
! 660: def factor(F)
! 661: @{
! 662: Mod = getopt(mod);
! 663: ModType = type(Mod);
! 664: if ( ModType == 1 ) /* 'mod' is not specified. */
! 665: return fctr(F);
! 666: else if ( ModType == 0 ) /* 'mod' is a number */
! 667: return modfctr(F,Mod);
! 668: @}
! 669: @end example
! 670:
! 671: @example
! 672: [0] load("factor")$
! 673: [1] factor(x^5-1);
! 674: [[1,1],[x-1,1],[x^4+x^3+x^2+x+1,1]]
! 675: [2] factor(x^5-1|mod=11);
! 676: [[1,1],[x+6,1],[x+2,1],[x+10,1],[x+7,1],[x+8,1]]
! 677: @end example
! 678:
! 679: 2 $BHVL\$N(B @code{factor()} $B$N8F$S=P$7$K$*$$$F(B, $B4X?tDj5A$N:]$K@k8@$5$l$?0z(B
! 680: $B?t(B @var{x^5-1}$B$N8e$m$K(B @var{|mod=11} $B$,CV$+$l$F$$$k(B. $B$3$l$O(B, $B4X?t<B9T;~(B
! 681: $B$K(B, @var{mod} $B$H$$$&(B keyword $B$KBP$7$F(B @var{11} $B$H$$$&CM$r3d$jEv$F$k$3$H(B
! 682: $B$r;XDj$7$F$$$k(B. $B$3$l$r%*%W%7%g%s;XDj$H8F$V$3$H$K$9$k(B. $B$3$NCM$O(B
! 683: @code{getopt(mod)} $B$G<h$j=P$9$3$H$,$G$-$k(B. 1 $BHVL\$N8F$S=P$7$N$h$&$K(B
! 684: @var{mod} $B$KBP$9$k%*%W%7%g%s;XDj$,$J$$>l9g$K$O(B, @code{getopt(mod)} $B$O7?(B
! 685: $B<1JL;R(B -1 $B$N%*%V%8%'%/%H$rJV$9(B. $B$3$l$K$h$j(B, $B;XDj$,$J$$>l9g$NF0:n$r(B if $BJ8(B
! 686: $B$K$h$j5-=R$G$-$k(B. @samp{|} $B$N8e$m$K$O(B, $BG$0U8D$N%*%W%7%g%s$r(B, @samp{,}
! 687: $B$G6h@Z$C$F;XDj$9$k$3$H$,$G$-$k(B.
! 688:
! 689: @example
! 690: [100] xxx(1,2,x^2-1,[1,2,3]|proc=1,index=5);
! 691: @end example
! 692:
1.1 noro 693:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>