Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. 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

image text in transcribed
1. 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 cx) (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. 1. 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 cx) (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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions