N Times Assignment
Revision as of 15:31, 12 October 2020 by Dennis.cosgrove (talk | contribs)
Background
We will implement in Java the (non-hall-of-fame) higher order function n-times which Prof. Grossman implemented in SML:
Code To Implement
NTimesHof
class: | NTimesHof.java | ![]() |
methods: | nTimes | |
package: | hof.ntimes.assignment | |
source folder: | src/main/java |
public static <T> T nTimes(Function<T, T> f, int n, T x)
NTimesHofApps
class: | NTimesHofApps.java | ![]() |
methods: | incrementNTimes doubleNTimes nthTail |
|
package: | hof.ntimes.assignment | |
source folder: | src/main/java |
public static int incrementNTimes(int n, int x)
public static int doubleNTimes(int n, int x)
public static <E> ImmutableList<E> nthTail(int n, ImmutableList<E> x)
Test
class: | NTimesTestSuite.java | ![]() |
package: | hof.ntimes.assignment | |
source folder: | src/test/java |