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.
The post Implement a memory cell encoded with functions appeared first on My Assignment Online.