The text book provides a game state ADT for 3-pile Nim, shown to the left in the menu as game-state-4b.scm.

Change nim3.scm so that it requires game-state-4b.scm and not game-state-4.scm.

If you haven't done so already, run the program while giving deliberately bad input from the human. Try giving:

In this step you will change your program so that it insists on valid input. When working correctly your program should behave as shown to the right.

The best solution is to modify the prompt procedure so that it takes a procedure as a second parameter that can be applied to the user input for validity. A third parameter specifies the string to display when the input is invalid:

  (define prompt
    (lambda (prompt-string valid? error-string)  ; note added parameters
      ...))
	
When the input fails the test, the error string should be displayed and the original prompt should be repeated (use iteration).

To test for non-numerical input, use the built-in integer? predicate, which takes an argument and tests for whether it is an integer.

Here is an example of how it should work, with user input in red:

	> (prompt "Please enter an integer: "
                  (lambda (x) (integer? x))
                  "Not an integer. Try again.")

        Please enter an integer: 
        3.14159
        Not an integer. Try again.
        Please enter an integer: 
        foo
        Not an integer. Try again.
        Please enter an integer: 
        13
        13
        >