Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Loops-Break/Retro/loops-break.retro
Normal file
22
Task/Loops-Break/Retro/loops-break.retro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
doc{
|
||||
A couple of helper functions to make the rest of the
|
||||
code more readable.
|
||||
}doc
|
||||
|
||||
: rand ( -n ) random 20 mod ;
|
||||
: . ( n- ) putn space ;
|
||||
|
||||
doc{
|
||||
One approach is to use a simple repeat/again loop, and
|
||||
a conditional exit. For instance:
|
||||
}doc
|
||||
|
||||
: foo ( - )
|
||||
repeat rand dup . 10 = if; rand . again ;
|
||||
|
||||
doc{
|
||||
The other approach uses a structured while loop with the
|
||||
second printing handled by a conditional clause.
|
||||
}doc
|
||||
|
||||
[ rand dup . 10 <> [ [ rand . ] ifTrue ] sip ] while
|
||||
Loading…
Add table
Add a link
Reference in a new issue