Better randomness

This commit is contained in:
flaviut 2014-07-17 11:46:49 -04:00
commit 54d85c8607

View file

@ -11,10 +11,9 @@ When inside a loop, `continue` can be used to skip the rest of the loop body and
Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops. Along with [its other uses](/block/), the `block` statement can be used to create a label so that it's possible to break out of nested loops.
``` nimrod ``` nimrod
import strutils import strutils, math
let answer = 4 # Chosen by a fair dice roll, let answer = random(10) + 1
# guaranteed to be random
while true: while true:
echo "I have a number from 1 to 10, what is it? " echo "I have a number from 1 to 10, what is it? "
let guess = parseInt(stdin.readLine) let guess = parseInt(stdin.readLine)