Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Scheme/DrRacket

Name: Anonymous 2013-02-12 17:57

How do you do this shit /prog/?

Write a Scheme function update-info that consumes an info structure (called data, in which all field
values are numbers), and a nonnegative number (called upper-bound). The function produces the number of
fields in data which are negative or are strictly greater than upper-bound. In addition, all fields of data
which are negative are replaced with 0, and all fields of data that are greater than upper-bound are replaced
with upper-bound.  Use field mutation operations to update data – you may not create any new info
structures in update-info. For example,


(define d (make-info 11 9 -7))
(update-info d 10)
2
d
(make-info 10 9 0)

Name: Anonymous 2013-02-12 18:31

>>1
Is there a convention on how this ``data'' would be represented and manipulated?

It could be from a linked list which you car and cdr directly to a silly closure which receives messages (as in SICP's implementation of objects) or actual records in Racket. The REPL output doesn't seem to match for any of such types.

Without knowing that, we can't help you.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List