1 Ht DP Teachpacks
2 Ht DC Teachpacks
On this page:
guess-with-gui
guess-with-gui-3
guess-with-gui-list
Version: 4.0.2

 

1.4 Guessing Numbers: guess.ss

The teachpack provides operations to play a guess-the-number game. Each operation display a GUI in which a player can choose specific values for some number of digits and then check the guess. The more advanced operations ask students to implement more of the game.

(guess-with-gui check-guess)  true

  check-guess : (-> number? number? symbol?)

The check-guess function consumes two numbers: guess, which is the user’s guess, and target, which is the randomly chosen number-to-be-guessed. The result is a symbol that reflects the relationship of the player’s guess to the target.

(guess-with-gui-3 check-guess)  true

  check-guess : (-> digit? digit? digit? number? symbol?)

The check-guess function consumes three digits (digit0, digit1, digit2) and one number (target). The latter is the randomly chosen number-to-be-guessed; the three digits are the current guess. The result is a symbol that reflects the relationship of the player’s guess (the digits converted to a number) to the target.

Note: digit0 is the least significant digit that the user chose and digit2 is the most significant one.

(guess-with-gui-list check-guess)  true

  check-guess : (-> (list-of digit?) number? symbol?)

The check-guess function consumes a list of digits (digits) and a number (target). The former is a list that makes up the user’s guess, and the latter is the randomly chosen number-to-be-guessed. The result is a symbol that reflects the relationship of the player’s guess (the digits converted to a number) to the target.

Note: the first item on digits is the least significant digit that the user chose, and the last one is the most significant digit.