Exercise3-6 <---> Exercise3-8
Exercise 3.7
Consider the bank account objects created by make-account, with the password modification described in exercise 3.3. Suppose that our banking system requires the ability to make joint accounts. Define a procedure make-joint that accomplishes this. Make-joint should take three arguments. The first is a password-protected account. The second argument must match the password with which the account was defined in order for the make-joint operation to proceed. The third argument is a new password. Make-joint is to create an additional access to the original account using the new password. For example, if peter-acc is a bank account with password open-sesame, then
(define paul-acc
- (make-joint peter-acc 'open-sesame 'rosebud))
will allow one to make transactions on peter-acc using the name paul-acc and the password rosebud. You may wish to modify your solution to exercise 3.3 to accommodate this new feature.
Ru: Русский текст упражнения
Scheme solution:
(define (make-joint account account-password joint-password)
(lambda (password-attempt action)
(if (eq? password-attempt joint-password)
(account account-password action)
(Error "Invalid password"))))
Other solutions goes here (use "#!code haskell", "#!code ocaml", etc. for syntax highlighting)
Exercise3-6 <---> Exercise3-8
Comments
| (define (make-joint co-holder co-holder_password new_password) (lambda(method passd1) (if (eq? pass1 new_password) (co-holder method co-holder_password) (display "The password is invalid")))) | ||||
| Posted by 130 at 2008-04-11 08:00:19 X | ||||