3.2 Lists and Trees
Develop the following functions and datatypes in the Beginning Student language.
procedure
(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.)
procedure
(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.)
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.
Obviously, you shouldn’t use string->number, because the point is for you to understand how such things work.
procedure
(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.
Converts
a list of of Fahrenheit measurements to a list of Celsius measurements.
Eliminates from lotp all toys whose price is greater than ua.
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).
Represents an unknown ancestor.
struct
name : string? birthyear : number? eyecolor : symbol? father : (or/c unknown? person?) mother : (or/c unknown? person?)
Represents a person.
procedure
(count-persons ftree) → number?
ftree : (or/c unknown? person?)
Returns the number of people in a family tree.
procedure
(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 2012.)
Produces a list of all eye colors in family tree. (An eye color may occur more than once in the list.)
Hint. Use append.