N Times Assignment

From CSE425S Wiki
Jump to navigation Jump to search

Background

We will implement in Java the (non-hall-of-fame) higher order function n-times which Prof. Grossman implemented in SML:

Functions as Arguments Video

Code To Implement

NTimesHof

class: NTimesHof.java Java.png
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 Java.png
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 Junit.png
package: hof.ntimes.assignment
source folder: src/test/java