USING: kernel random io math.parser math combinators ; IN: high-low : guess ( -- guess ) "Your guess? " write flush readln string>number ; : check-guess ( answer guess -- succeeded? ) { { [ 2dup > ] [ 2drop "Too low" print f ] } { [ 2dup < ] [ 2drop "Too high" print f ] } [ 2drop "You win!" print t ] } cond ; : game-loop ( answer -- ) dup guess check-guess [ drop ] [ game-loop ] if ; : start ( max -- ) random game-loop ;