SICP Exercise 3.4 call-the-cops

Exercise 3.4.  Modify the make-account procedure of exercise 3.3 by adding another local state variable so that, if an account is accessed more than seven consecutive times with an incorrect password, it invokes the procedure call-the-cops.

SOLUTION

I converted the explicit 'dispatch' procedure into a lambda function. This made it more elegant.

The code is here:

SICP Exercise 3.4 call-the-cops

Comments

Popular posts from this blog

SICP Exercise 2.56 differentiation rule

SICP Exercise 1.28 (Miller-Rabin Test)

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions