logo
 
Homework 2 - Chapter 6-9
CptS 355 - Programming Language Design
Washington State University
Home
Notices
Calendar
Homework
Syllabus
Resources
People

This homework set is due Monday, April 19 in class. Solutions are to be typed, not handwritten.
  1. In class I gave an access function for computing the location of array element a[k1,k2] for a two-dimensional array with subscript ranges [l1:u1, l2:u2] -- i.e. l1 is the lower bound of the first subscript, u1 is its upper bound, etc. The function I gave was for an array stored in row-major order. Give the corresponding access function if the array is stored in column-major order. Assume that the upper bound in each dimension is the first invalid subscript. That is, the array has u1-l1 rows and u2-l2 columns.
  2. In many languages, beginning with Pascal, discriminated union types are called variant records and may contain fields other than those in the variant part. For an example see the the code at the top of page 270 in Sebesta. The variant part is usually required to be after the other fields. Why?
  3. Chapter 7, problem (not review question) 9.
  4. Chapter 7, problem 11.
  5. Chapter 7, programming exercise 1. Identify the compiler(s) you used for your experiments.
  6. Chapter 8, programming exercises 4, 5 and 6. Turn in only a printout of your code -- I don't want files. This means that you do not absolutely have to compile and execute your code. On the other hand, valid and correct code is required so maybe compiling and running it would help to get it right...
  7. Chapter 9, problem 5.
  8. Chapter 9, programming exercise 4. In addition to explaining the results make sure that you include a copy of the code that you tested and that you describe the results that were observed.

                                                                                                                                                                                                                                                                                                                                             
  (c) 2003 Curtis Dyreson, (c) 2004 Carl H. Hauser           E-mail questions or comments to Prof. Carl Hauser