On this page:
2.10.1 Objectives
2.10.2 Exercises (due 2011/  10/  17 08:  45:  00)
2.10.3 Optional Exercises (due 2011/  10/  21 08:  45:  00)
2.10.4 Notes

2.10 More on Lists

Inside every list

is just another list

(except for empty)

2.10.1 Objectives

At the end of this class, you should know:
  • what is meant a list

At the end of this class, you should be able:

2.10.2 Exercises (due 2011/10/17 08:45:00)

1. Write a function called containsHuh that determines if a string given as an input is in a list of strings.

2. Write a function called convertList that consumes a list of digits and returns the corresponding number. The first digit is the least significant digit. (Refer to convert3 if you are unsure what this means.)

3. Develop the function delta, which consumes two price lists, that is, lists of numbers. The first represents the inventory at the beginning of a time period, the second one the inventory at the end. The function outputs the difference in value. If the value of the inventory has increased, the result is positive; if the value has decreased, it is negative.

4. Develop a function longestString that returns the longest string in a list of strings.

2.10.3 Optional Exercises (due 2011/10/21 08:45:00)

5. Write a function called anyFreezingHuh that determines if any temperature in a list of Fahrenheit temperatures is below freezing.

6. Define the function averagePrice. It consumes a list of toy prices and computes the average price of a toy. The average is the total of all prices divided by the number of toys.

2.10.4 Notes

These notes are primarily for my sake, but I don’t see any reason to hide them from you.

Write containsPluto

=> bool

 

Use hand analogy

 

Write reference

 

Use train car analogy

 

Write containsLessThanHuh

 

Write theWholeUniverse

 -> string

 

Make number list

 

Write containsHuh (on numbers)