From: Ramakrishnan Muthukrishnan Date: Mon, 13 Jun 2011 16:52:13 +0000 (+0530) Subject: solution to 3.44 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/flags/%22doc.html/module-simplejson.html?a=commitdiff_plain;h=22c9ed85943b0b665c9da80590df64862f812355;p=sicp.git solution to 3.44 --- diff --git a/src/sicp/ex3_44.rkt b/src/sicp/ex3_44.rkt new file mode 100644 index 0000000..7484364 --- /dev/null +++ b/src/sicp/ex3_44.rkt @@ -0,0 +1,19 @@ +#lang racket + +;; Consider the problem of transferring an amount from one account to +;; another. Ben Bitdiddle claims that this can be accomplished with the +;; following procedure, even if there are multiple people concurrently +;; transferring money among multiple accounts, using any account +;; mechanism that serializes deposit and withdrawal transactions, for +;; example, the version of make-account in the text above. + +(define (transfer from-account to-account amount) + ((from-account 'withdraw) amount) + ((to-account 'deposit) amount)) + +#| + +Since withdraw and deposit themselves are 'atomic' (or rather 'safe') +there is no problem with this routine. + +|# \ No newline at end of file