Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now
Prices start at $5 per page · plagiarism-free papers · free revisions for 14 days 24/7 support: support@bestwriters.com
Uncategorized

Implement a memory cell encoded with functions

  • Posted
  • Authoradmin
  • Length204 words
  • Reading time1 min
Write My Assignment FREE

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.

Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

✓ Native UK, USA & Australia writers ✓ Deadline from 3 hours ✓ 100% Plagiarism-Free — Turnitin included ✓ Unlimited free revisions ✓ Free to submit — compare quotes

admin

Academic writer and editor at BestWriters.

Get your paper off your plate tonight

Post your instructions for free. Prices start at $5 per page.

Place an order