On this page:
check-temps1
check-temps
convert
average-price
convert FC
eliminate-exp
suffixes
unknown
person
count-persons
average-age
eye-colors

3.4 Lists and Trees

You must complete this assignment by yourself.

You must submit this in an archive named "lists.zip". This archive must contain a folder named "lists". This folder must contain all the files specified below. You must attach "lists.zip" to an email whose subject is "BYU - Fall 2011 - CS 330 - lists" and whose message body contains the name of everyone on your team (each on a separate line.) You must send this email to jay@cs.byu.edu before 5pm (Provo time) on 9/8. Ensure that what you are satisfied with what you submit, because only your chronologically first submission will be graded. Ensure that you follow these instructions exactly, since submissions that do not meet these requirements (i.e. do not have the correct format) will receive no credit, despite the time and energy you put into the assignment. Please see Turn In Policy for more information.

You must submit this in a file named "lists.rkt".

Develop the following functions and datatypes in the Beginning Student language.

(check-temps1 temps)  boolean?
  temps : (listof number?)
Consumes a list of temperature measures and checks whether all measurements are between 5 and 95 degrees celsius (inclusively.)

(check-temps temps low high)  boolean?
  temps : (listof number?)
  low : number?
  high : number?
Consumes a list of temperature measures and checks whether all measurements are between low and high degrees celsius (inclusively.)

(convert digits)  number?
  digits : (listof number?)
Consumes a list of digits (numbers between 0 and 9) and produces the corresponding number. The first digit is the least significant, and so on.

For example, (convert (cons 1 (cons 2 (cons 3 empty)))) should result in 321.

(average-price prices)  number?
  prices : (listof number?)
Consumes a list of toy prices and computes the average price of a toy. The average is total of all prices divided by the number of toys.

(convertFC fahrenheit)  (listof number?)
  fahrenheit : (listof number?)
Converts a list of of Fahrenheit measurements to a list of Celsius measurements.

(eliminate-exp ua lotp)  (listof number?)
  ua : number?
  lotp : (listof number?)
Eliminates from lotp all toys whose price is greater than ua.

(suffixes l)  (listof list?)
  l : list?
Produces a list of a suffixes of l.

For example, (suffixes (list 'a 'b 'c 'd)) produces (list (list 'a 'b 'c 'd) (list 'b 'c 'd) (list 'c 'd) (list 'd) empty).

(struct unknown ()
  #:extra-constructor-name make-unknown)
Represents an unknown ancestor.

(struct person (name birthyear eyecolor father mother)
  #:extra-constructor-name make-person)
  name : string?
  birthyear : number?
  eyecolor : symbol?
  father : (or/c unknown? person?)
  mother : (or/c unknown? person?)
Represents a person.

(count-persons ftree)  number?
  ftree : (or/c unknown? person?)
Returns the number of people in a family tree.

(average-age ftree)  number?
  ftree : (or/c unknown? person?)
Returns the average age of all the people in the family tree. (Assume the current year is 2011.)

(eye-colors ftree)  (listof symbol?)
  ftree : (or/c unknown? person?)
Produces a list of all eye colors in family tree. (An eye color may occur more than once in the list.)

Hint. Use append.