From 87b295369de0d53abee6c9cd6ad4a5546ffaf490 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com> Date: Sat, 2 Apr 2011 13:12:16 +0530 Subject: [PATCH] mid air commit to solution 3.31 --- src/sicp/ex3_31.rkt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/sicp/ex3_31.rkt diff --git a/src/sicp/ex3_31.rkt b/src/sicp/ex3_31.rkt new file mode 100644 index 0000000..4b78357 --- /dev/null +++ b/src/sicp/ex3_31.rkt @@ -0,0 +1,32 @@ +#lang racket + +#| + +If we don't call the proc in the add-action! procedure then the outputs for the +given inputs will be in some undefined default states. They won't reflect the +logic that the function blocks are representing. + +Let us take half adder example: + +(define (half-adder a b s c) + (let ((d (make-wire)) (e (make-wire))) + (or-gate a b d) + (and-gate a b c) + (inverter c e) + (and-gate d e s) + 'ok)) + +If accept-action-proc! is defined without the call to proc, i.e. + +(define (accept-action-proc! proc) + (set! action-procedures (cons proc action-procedures)) + +then, let us see what happens. + +The or-gate definition will call add-action on both its inputs a and b. make-wire +by default sets the wire value as 0. So, for the default case, the inputs to the +half-adder will be 0 and 0 and the output of the or-gate and and-gate will be 0. +i.e. D = 0, C = 0. +E will also be 0. So, S = 0 C = 0, irrespective of the initial values of a and b. + +|# \ No newline at end of file -- 2.45.2