From: Ramakrishnan Muthukrishnan Date: Sat, 2 Apr 2011 07:42:16 +0000 (+0530) Subject: mid air commit to solution 3.31 X-Git-Url: https://git.rkrishnan.org/cyclelanguage?a=commitdiff_plain;h=87b295369de0d53abee6c9cd6ad4a5546ffaf490;p=sicp.git mid air commit to solution 3.31 --- 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