Lab 6 — Practice with `for each` and lists
Skills: 3
For all of these problems, first implement them with for each
. Afterwards, see if there is a way to implement them with map
or filter
(without using any mutable variables). For some, it should be possible with just a single call to L.map
or L.filter
-- but for others in order to you it you may need to also use other functions like L.length
.
- Design a function
absolute-values
that takes a list of numbers and returns a new list where each number has been converted to its absolute value (usenum-abs
). - Design a function
exactly-three-chars
that takes a list of strings and returns a new list containing only the strings that have exactly 3 characters. - Design a function
all-even
that takes a list of numbers and returnstrue
if every number in the list is even,false
otherwise. - Design a function
count-in-range
that takes a list of numbers, a minimum value, and a maximum value, and returns how many numbers in the list are between the min and max (inclusive).