Higher-order Functions Map And Reduce Assignment
Jump to navigation
Jump to search
Contents
Java
Code to Investigate
VolleyballMapClient
List<Player> roster = VolleyballRoster.WASHU_2021.players(); List<Integer> heights = MapUtils.map((player) -> { return player.height(); }, roster); heights.forEach((height) -> { System.out.println(height); });
Code to Implement
map
class: | MapUtils.java | |
methods: | map | |
package: | hof.map.exercise | |
source folder: | student/src/main/java |
method: <T, R> List<R> map(Function<T, R> f, List<T> list))
(sequential implementation only)
clients
class: | MapClients.java | |
methods: | mapToLengths mapToStrictlyLessThan |
|
package: | hof.map.exercise | |
source folder: | student/src/main/java |
We created a couple of utility methods which invoke map with a custom lambda.
mapToLengths
method: List<Integer> mapToLengths(List<String> texts)
(sequential implementation only)
mapToStrictlyLessThan
method: List<Boolean> mapToStrictlyLessThan(List<Integer> xs, int threshold)
(sequential implementation only)
Test
class: | _MapTestSuite.java | |
package: | hof.map.group | |
source folder: | testing/src/test/java |