Assignment 4

Assignment 4 - CS 136 Fall 2009 Kate Larson Due Tuesday...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 136 Fall 2009 Kate Larson Assignment 4 Due Tuesday, October 20, 2009, 10pm Language level : Module (full PLT Scheme). You can use elementary mutation ( set! and set- box! ) in this assignment. Questions 4 and 5 involve programming in C. To submit : mlist.ss , stack.ss , stack-driver.ss , spaghetti.ss , sum.c , sum-driver.c , bell.c , bell-driver.c 1. Boxes make mutable structures and lists unnecessary since we can use immutable structures and lists whose ±elds contain boxes. In this question you will write some basic functions to implement mutable lists, mlists , in this fashion. You will then be able to use these functions in future questions, if you want. We need to start with a de±nition of an empty mutable list, and we want to ensure that an empty mlist , which we will call mlist-empty , is not confused with other Scheme values. We can do this by de±ning a structure. ( defne-struct mt ()) ( defne mlist-empty ( make-mt )) For a mutable version of cons we can de±ne a new structure kons ( defne-struct kons ( Fbox rbox ) #:transparent ) Data defnition: A mlist is either mlist-empty or is ( make-kons Fb rb ) where Fb is a box containing a Scheme value and rb is a box containing a mlist . Write the following basic functions: mlist-empty? , which consumes one argument and tests if that argument is an empty mlist (a mlist-empty according to the data de±nition). This function should produce a Boolean value. my-cons? , which consumes one argument and tests if that argument is an mlist satis- fying the second “nonempty” case in the data de±nition (a ( make-kons Fb rb )). This function should produce a Boolean value.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

Assignment 4 - CS 136 Fall 2009 Kate Larson Due Tuesday...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online