]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex3_44.rkt
solutions to 4.38, 4.39 and 4.40
[sicp.git] / src / sicp / ex3_44.rkt
1 #lang racket
2
3 ;; Consider the problem of transferring an amount from one account to
4 ;; another. Ben Bitdiddle claims that this can be accomplished with the
5 ;; following procedure, even if there are multiple people concurrently 
6 ;; transferring money among multiple accounts, using any account 
7 ;; mechanism that serializes deposit and withdrawal transactions, for 
8 ;; example, the version of make-account in the text above.
9
10 (define (transfer from-account to-account amount)
11   ((from-account 'withdraw) amount)
12   ((to-account 'deposit) amount))
13
14 #|
15
16 Since withdraw and deposit themselves are 'atomic' (or rather 'safe')
17 there is no problem with this routine. 
18
19 |#