Difference between revisions of "N Times Assignment"

From CSE425S Wiki
Jump to navigation Jump to search
(Created page with "=Code To Implement= ==NTimesHof== {{JavaToImplement|NTimesHof|nTimes|hof.ntimes.assignment}} <nowiki>public static <T> T nTimes(Function<T, T> f, int n, T x)</nowiki> ==NTi...")
 
 
Line 1: Line 1:
 +
=Background=
 +
We will implement in Java the (non-hall-of-fame) higher order function n-times which Prof. Grossman implemented in SML:
 +
 +
[https://www.coursera.org/learn/programming-languages/lecture/qxDSS/functions-as-arguments Functions as Arguments Video]
 +
 
=Code To Implement=
 
=Code To Implement=
 
==NTimesHof==
 
==NTimesHof==

Latest revision as of 15:31, 12 October 2020

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