version 1.231, 2011/01/01 14:22:48
|
version 1.232, 2011/08/10 13:55:03
|
Line 5384 matches). Example:
|
Line 5384 matches). Example:
|
endcase ; |
endcase ; |
@end example |
@end example |
|
|
|
You can also use (the non-standard) @code{?of} to use @code{case} as a |
|
general selection structure for more than two alternatives. |
|
@code{?Of} takes a flag. Example: |
|
|
|
@example |
|
: sgn ( n1 -- n2 ) |
|
\ sign function |
|
case |
|
dup 0< ?of drop -1 endof |
|
dup 0> ?of drop 1 endof |
|
dup \ n1=0 -> n2=0; dup an item, to be consumed by ENDCASE |
|
endcase ; |
|
@end example |
|
|
@progstyle |
@progstyle |
To keep the code understandable, you should ensure that you change the |
To keep the code understandable, you should ensure that you change the |
stack in the same way (wrt. number and types of stack items consumed |
stack in the same way (wrt. number and types of stack items consumed |
and pushed) on all paths through a selection construct. |
and pushed) on all paths through a selection structure. |
|
|
@node Simple Loops, Counted Loops, Selection, Control Structures |
@node Simple Loops, Counted Loops, Selection, Control Structures |
@subsection Simple Loops |
@subsection Simple Loops |
Line 5681 Another group of control structure words
|
Line 5695 Another group of control structure words
|
doc-case |
doc-case |
doc-endcase |
doc-endcase |
doc-of |
doc-of |
|
doc-?ofx |
doc-endof |
doc-endof |
|
|
|
|