Your goal is to implement a memory cell encoded with functions as data. Recall §2.1.3 of the SICP…

STUCK with your assignment? When is it due? Hire our professional essay experts who are available online 24/7 for an essay paper written to a high standard at a reasonable price.


Order a Similar Paper Order a Different Paper

Your goal is to implement a memory cell encoded with functions as data. Recall §2.1.3 of the SICP

book, in particular the implementation of functions cons, car, and cdr.

A memory cell is a function value that expects exactly one argument: a list. According to the contents

of the list, the memory cell should perform one of two operations:

• Operation set. The argument is a list with exactly one element. The memory cell must return a

new memory cell.

• Operation get. The argument is an empty list. The memory cell returns the value contained in

the memory cell.

The following two definitions can be used to interact with any memory cell:

(define (cell-get c) (c (list)))

(define (cell-set c x) (c (list x)))

(a) Implement a read-write cell. Function rw-cell takes a number that initializes the memory cell.

Operation set returns a new cell with the value given. Operation get returns the contents of the

cell.

(b) Implement a read-only cell. Function ro-cell takes a number and return a read-only cell. Operation

set should not change the stored value and return a cell with the same contained value. Operation

get returns the initial value.

Writerbay.net

Everyone needs a little help with academic work from time to time. Hire the best essay writing professionals working for us today!

Get a 15% discount for your first order


Order a Similar Paper Order a Different Paper