Last active 5 days ago Unlisted

translated from wul

gregori's Avatar gregori revised this gist 5 days ago. Go to revision

No changes

gregori's Avatar gregori revised this gist 5 days ago. Go to revision

No changes

gregori's Avatar gregori revised this gist 5 days ago. Go to revision

1 file changed, 6 insertions, 6 deletions

gistfile1.txt

@@ -14,19 +14,19 @@
14 14 | :: pick a number from $min to $max |
15 15 :@rpn: ( random ) :@rpn data: 100
16 16
17 - | :@rpn data: $guess |
18 - :guess: $guess
17 + | :@rpn data: $target |
18 + :target: $target
19 19
20 20 | :: ask user for a number |
21 21 :@js:
22 22 const input = prompt("Guess what number I'm thinking of between 1 and 100", "");
23 - f("target", input)
23 + f("guess", input)
24 24
25 - | :: compare guess with target :guess: $n? :target: $n |
25 + | :: compare guess with target :target: $n? :guess: $n |
26 26 :state: win
27 27
28 - | :: compare guess with target :guess: $n? :target: $m |
29 - :state: $state :target: $m
28 + | :: compare guess with target :target: $n? :guess: $m |
29 + :state: $state :guess: $m
30 30 :@js:
31 31 if($n > $m) {
32 32 $state = "Too low!"

gregori's Avatar gregori revised this gist 5 days ago. Go to revision

1 file changed, 2 insertions, 2 deletions

gistfile1.txt

@@ -19,7 +19,7 @@
19 19
20 20 | :: ask user for a number |
21 21 :@js:
22 - const input = prompt("1-100", "");
22 + const input = prompt("Guess what number I'm thinking of between 1 and 100", "");
23 23 f("target", input)
24 24
25 25 | :: compare guess with target :guess: $n? :target: $n |
@@ -35,7 +35,7 @@
35 35 }
36 36
37 37 | :: decide on next step :state: win |
38 - :@js: alert("you win!");
38 + :@js: alert("OMG you totally got it! That's it!!");
39 39
40 40 | :: decide on next step :state: $state |
41 41 :@js: alert($state);

gregori's Avatar gregori revised this gist 6 days ago. Go to revision

1 file changed, 28 insertions, 27 deletions

gistfile1.txt

@@ -1,44 +1,45 @@
1 - || :comment: play a guessing game from 1 to 100
1 + ||:@include: lib/rpn.nv
2 +
3 + || :: play a guessing game from 1 to 100
2 4
3 5 | :: play a guessing game from $min to $max |
4 - :: . pick a number from $min to $max
6 + :: . pick a number from $min to $max
5 7 . begin game loop
6 8
7 9 | :: begin game loop |
8 - :print: "enter a guess"
9 - :: .read a number
10 + :: . ask user for a number
10 11 . compare guess with target
11 12 . decide on next step
12 13
13 14 | :: pick a number from $min to $max |
14 - :target: $n
15 - :@js: $n = tostring(Math.floor(Math.random() * (@max - @min) + @min))
16 -
17 - | :: read a number |
18 - :guess: $n :@js:
19 - repeat
20 - $n = io.read(\"*line\")
21 - until tonumber($n)
22 - $n = tostring(tonumber($n))
15 + :@rpn: ( random ) :@rpn data: 100
16 +
17 + | :@rpn data: $guess |
18 + :guess: $guess
19 +
20 + | :: ask user for a number |
21 + :@js:
22 + const input = prompt("1-100", "");
23 + f("target", input)
23 24
24 - | :: compare guess with target :guess: $n :target: $n |
25 + | :: compare guess with target :guess: $n? :target: $n |
25 26 :state: win
26 27
27 - | :: compare guess with target :guess: $n :target: $m |
28 - :state: $state :target: $m :@js: "
29 - if tonumber($n) < tonumber($m) then
30 - $state = \"too low\"
31 - else
32 - $state = \"too high\"
33 - end
34 - "
28 + | :: compare guess with target :guess: $n? :target: $m |
29 + :state: $state :target: $m
30 + :@js:
31 + if($n > $m) {
32 + $state = "Too low!"
33 + } else if($n < $m) {
34 + $state = "Too high!"
35 + }
35 36
36 - |:: decide on next step :state: "win" |
37 - :print: "you win!"
37 + | :: decide on next step :state: win |
38 + :@js: alert("you win!");
38 39
39 - | decide on next step :state: $s |
40 - :print: $s
40 + | :: decide on next step :state: $state |
41 + :@js: alert($state);
41 42 :: begin game loop
42 43
43 44 | :print: $message |
44 - :@js: print($message)
45 + :@js: print($message);

gregori's Avatar gregori revised this gist 6 days ago. Go to revision

1 file changed, 17 insertions, 11 deletions

gistfile1.txt

@@ -1,22 +1,25 @@
1 - || :: play a guessing game from 1 to 100
1 + || :comment: play a guessing game from 1 to 100
2 2
3 3 | :: play a guessing game from $min to $max |
4 4 :: . pick a number from $min to $max
5 5 . begin game loop
6 6
7 7 | :: begin game loop |
8 - :print: enter a guess
9 - :: . read a number
8 + :print: "enter a guess"
9 + :: .read a number
10 10 . compare guess with target
11 11 . decide on next step
12 12
13 13 | :: pick a number from $min to $max |
14 14 :target: $n
15 - :@js: "$n = Math.floor(Math.random() * (100 - 1) + 1)"
15 + :@js: $n = tostring(Math.floor(Math.random() * (@max - @min) + @min))
16 16
17 17 | :: read a number |
18 - :comment: replacing this with a hardcoded number because i can't figure js out
19 - :guess: 48
18 + :guess: $n :@js:
19 + repeat
20 + $n = io.read(\"*line\")
21 + until tonumber($n)
22 + $n = tostring(tonumber($n))
20 23
21 24 | :: compare guess with target :guess: $n :target: $n |
22 25 :state: win
@@ -24,15 +27,18 @@
24 27 | :: compare guess with target :guess: $n :target: $m |
25 28 :state: $state :target: $m :@js: "
26 29 if tonumber($n) < tonumber($m) then
27 - $state = "too low"
30 + $state = \"too low\"
28 31 else
29 - $state = "too high"
32 + $state = \"too high\"
30 33 end
31 34 "
32 35
33 - | :: decide on next step :state: "win" |
36 + |:: decide on next step :state: "win" |
34 37 :print: "you win!"
35 38
36 - | :: decide on next step :state: $s |
39 + | decide on next step :state: $s |
37 40 :print: $s
38 - :: begin game loop
41 + :: begin game loop
42 +
43 + | :print: $message |
44 + :@js: print($message)

gregori's Avatar gregori revised this gist 6 days ago. Go to revision

1 file changed, 38 insertions

gistfile1.txt(file created)

@@ -0,0 +1,38 @@
1 + || :: play a guessing game from 1 to 100
2 +
3 + | :: play a guessing game from $min to $max |
4 + :: . pick a number from $min to $max
5 + . begin game loop
6 +
7 + | :: begin game loop |
8 + :print: enter a guess
9 + :: . read a number
10 + . compare guess with target
11 + . decide on next step
12 +
13 + | :: pick a number from $min to $max |
14 + :target: $n
15 + :@js: "$n = Math.floor(Math.random() * (100 - 1) + 1)"
16 +
17 + | :: read a number |
18 + :comment: replacing this with a hardcoded number because i can't figure js out
19 + :guess: 48
20 +
21 + | :: compare guess with target :guess: $n :target: $n |
22 + :state: win
23 +
24 + | :: compare guess with target :guess: $n :target: $m |
25 + :state: $state :target: $m :@js: "
26 + if tonumber($n) < tonumber($m) then
27 + $state = "too low"
28 + else
29 + $state = "too high"
30 + end
31 + "
32 +
33 + | :: decide on next step :state: "win" |
34 + :print: "you win!"
35 +
36 + | :: decide on next step :state: $s |
37 + :print: $s
38 + :: begin game loop
Newer Older