From 22c9ed85943b0b665c9da80590df64862f812355 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Mon, 13 Jun 2011 22:22:13 +0530 Subject: [PATCH] solution to 3.44 --- src/sicp/ex3_44.rkt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/sicp/ex3_44.rkt 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 -- 2.45.2