||:@include: lib/rpn.nv || :: play a guessing game from 1 to 100 | :: play a guessing game from $min to $max | :: . pick a number from $min to $max . begin game loop | :: begin game loop | :: . ask user for a number . compare guess with target . decide on next step | :: pick a number from $min to $max | :@rpn: ( random ) :@rpn data: 100 | :@rpn data: $guess | :guess: $guess | :: ask user for a number | :@js: const input = prompt("1-100", ""); f("target", input) | :: compare guess with target :guess: $n? :target: $n | :state: win | :: compare guess with target :guess: $n? :target: $m | :state: $state :target: $m :@js: if($n > $m) { $state = "Too low!" } else if($n < $m) { $state = "Too high!" } | :: decide on next step :state: win | :@js: alert("you win!"); | :: decide on next step :state: $state | :@js: alert($state); :: begin game loop | :print: $message | :@js: print($message);