RosettaCodeData/Task/Loops-Break/Dc/loops-break.dc

26 lines
620 B
Plaintext

1 ss [s = seed of the random number generator]sz
0k [scale = 0]sz
[Function r: Push a random number from 0 to 20.]sz
[
[2Q]SA
[
[Formula (from POSIX) for random numbers of low quality.]sz
ls 1103515245 * 12345 + 4294967296 % d ss [Compute next s]sz
65536 / [it = s / 65536]sz
d 16 !>A [Break loop if 16 <= it]sz
sz 0 0 =B [Forget it, continue loop]sz
]SB 0 0 =B
20 % [Push it % 20]sz
LA sz LB sz [Restore A, B]sz
]sr
[2Q]sA
[
0 0 =r p [Print 1st number.]sz
10 =A [Break if 10 == it.]sz
0 0 =r p sz [Print 2nd number.]sz
0 0 =B [Continue loop.]sz
]sB 0 0 =B