diff options
| author | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-11 22:34:24 -0500 |
|---|---|---|
| committer | nic-gaffney <gaffney_nic@protonmail.com> | 2023-04-11 22:34:24 -0500 |
| commit | 81c56242feb2951cece9b4876edb2e298548a5c1 (patch) | |
| tree | fd205ddef70c18ff5e251fa7436adcbe3dcf2c8b /examples/guessing.sloth | |
| parent | a875d1626dd74a6dee31ef056f3ffe874256a8e2 (diff) | |
| download | sloth-81c56242feb2951cece9b4876edb2e298548a5c1.tar.gz | |
Mutability should work now (very jank)
Diffstat (limited to 'examples/guessing.sloth')
| -rw-r--r-- | examples/guessing.sloth | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/examples/guessing.sloth b/examples/guessing.sloth index 01f0796..830519b 100644 --- a/examples/guessing.sloth +++ b/examples/guessing.sloth @@ -1,26 +1,16 @@ val computer = random(1, 10); - var tries = 0; var correct = false; - while !correct { print("\nPick a number between 1 and 10: "); val human = parse_int(readln()); - - if human == computer { - println("You guessed the same number as me!"); - var correct = true; - } - - if human > computer { - println("Your guess was too high."); - } - - if human < computer { - println("Your guess was too low."); + if human == computer {println("You guessed the same number as me!"); + correct = true; } + if human > computer {println("Your guess was too high.");} + if human < computer {println("Your guess was too low.");} - var tries = tries + 1; + tries = tries + 1; } println("\nIt took you ", tries, " tries to guess correctly!"); |
