Due: Monday 10/28 10:00am
Submission name: work17.rkt
Write the following functions using recursion. The only list-specific functions you should use are first
, rest
, list
, null?
, and cons
. Include multiple test cases for each function.
(count value g)
- Assume
g
is a list of numbers andvalue
is a number. - Returns the number of times
value
appears ing
.
- Assume
(listMin g currentMin)
- Assume
g
is a list of numbers andcurrentMin
is a number. - Returns the smallest value in
g
. - To test this, you’ll need to use
currentMin
effectively. Initially, you’ll want a value larger than any other possible value.+inf.0
is a valid value in Racket representing the smallest possible value.
- Assume
(countDown n)
- Assume
n
is a positive integer. - Returns a list containing all the integers from
n
to0
.
- Assume
(doublify g)
- Assume
g
is a list containing only numbers. - Returns a list containing the values of
g
times 2.
- Assume
(myMap f g)
- Assume
f
is a function andg
is a list. - Works the same way as
map
, so it should return a new list wheref
is applied to each element ofg
.
- Assume
(reverse-build-list n f)
- Assume
n
in a positive integer andf
is a function. - Works like
build-list
but in reverse, so the first element should be(f n)
and the last should be(f 0)
. - Question to ponder: What would you need to do to get this to work the same way as
build-list
?
- Assume