Guess


guess.ss

The teachpack guess.ss 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.

The teachpack provides three operations:

  • repl : check-guess -> true;
    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.

  • repl3 : check-guess -> true;
    The check-guess function consumes three digits and one number: digit0, digit1, digit2, which make up 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 (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.
  • repl-for-list : check-guess -> true;
    The check-guess function consumes a list of digits and one number: digits, a list that makes up 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 (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.