programgames/guess/play.xtl

source · imports g: games/guess/NumberGuess.xtl; p: lib/Play.xtl

said : Char

value · line 8
said ← p̲rint! "--- GUESS THE NUMBER ---"

said : Char

value · line 9
said ← p̲rint! "I AM THINKING OF A NUMBER BETWEEN 1 AND 100."

t : Int

value · line 10
t ← ᵍn̲ew ᵍtop
Used in: ᵘt̲urn

ᵘa̲sk : Any a => a -> Int

function · line 13

A guess: the first number typed, or it asks again.

ᵘa̲sk ← { n →
  g ← ᵖn̲umber "YOUR GUESS ?"
  g ≥ 0 ? g◆ ᵘa̲sk n
}

ᵘt̲urn : Num a => a -> a

function · line 18

Answer each guess until one is right; how many it took.

ᵘt̲urn ← { n →
  r ← t ᵍm̲ove ᵘa̲sk n
  shown ← p̲rint! ᵍr̲eply r
  r = 0 ? n◆ ᵘt̲urn n + 1
}
Used in: ᵘt̲urn, n

n : Int

value · line 23
n ← ᵘt̲urn 1