|| :comment: 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 |
	:print: "enter a guess"
::  .read a number
    . compare guess with target
    . decide on next step

| :: pick a number from $min to $max |
	:target: $n 
	:@js: $n = tostring(Math.floor(Math.random() * (@max - @min) + @min))

| :: read a number |
    :guess: $n :@js: 
        repeat
            $n = io.read(\"*line\")
        until tonumber($n)
        $n = tostring(tonumber($n))
    
| :: compare guess with target :guess: $n :target: $n |
  :state: win

| :: compare guess with target :guess: $n :target: $m |
    :state: $state :target: $m :@js: "
        if tonumber($n) < tonumber($m) then
            $state = \"too low\"
        else
            $state = \"too high\"
        end
    "

|:: decide on next step :state: "win" |
    :print: "you win!"

| decide on next step :state: $s |
	:print: $s
    :: begin game loop

| :print: $message |
    :@js: print($message)