-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathguess.spd
More file actions
executable file
·39 lines (32 loc) · 1.1 KB
/
guess.spd
File metadata and controls
executable file
·39 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/spd
// compare this file to the original and see how much smaller (and faster?) it is in speedie!
https://github.com/contextfreecode/jai-comparisons/blob/main/guess.jai
main (|int| Highest_Number = 100)
zalgoline "Finished in ${game(Highest_Number).play}\n\n"
class game
|int| answer
|int| last = int.min
|int| high
constructor (|int| high)
.high = high
.answer = high() + 1
function play (|int|)
"::Guess a number between 1 and $.high::"
while ++Rz
|| guess = .ask
printline .report(guess)
.last = guess
loop guess != .answer
function report (|int| guess, |string|)
if guess < 1 or guess > .high: return "I said between 1 and $.high!! What would I expect from a ${$1} like you!"
if guess == .last: return "you just said $guess you ${$1}"
if guess < .answer: return "too low you ${$1}"
if guess > .answer: return "you ${$1} $guess is way too high"
return "correct!"
function ask (|int|)
while
|| word = app.input
|| result = word.int
return result
zalgoline "Uhhhh? $word? just what I expect from a ${$1}\n\n"
StdErr.clear // why not