Question: Write out the procedures for 3.1 and 3.2 in Scheme. ; 1 (define and-gate (lambda (a b) (if (= a b 1) 1 0))) (define

Write out the procedures for 3.1 and 3.2 in Scheme.

; 1 (define and-gate (lambda (a b) (if (= a b 1) 1 0)))

(define or-gate (lambda (a b) (if (= a 1) 1 (if (= b 1) 1 0))))

(define xor-gate (lambda (a b) (if (= a b) 0 1)))

; 2.1 (define (sum-bit X A B) (XOR-gate X (XOR-gate A B)))

; 2.2 (define (carry-bit X A B) (OR-gate (AND-gate A B) (OR-gate (AND-gate X A) (AND-gate X B))))

; 2.3 (define (bit-adder X A B) (cons (sum-bit X A B) (carry-bit X A B)))

3.1 Define a procedure (tail lst), which returns the last element of lst.

3.2 Define a procedure (rmtail lst), which returns the list without the last element of lst. For example, (rmtail (1 3 5 6 8)) should return (1 3 5 6).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!