summaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-12-01 20:20:27 -0500
committerBen Culkin <scorpress@gmail.com>2020-12-01 20:20:27 -0500
commit097a33bc2ecaa64a664550ddd62ccd8de47c51d0 (patch)
treedf9680c1f33fddf4dcbe538593ee73703afb91ce /src/example
parentc85db1bef75e5c9b7287ab7fdb6e1380d577c674 (diff)
An assortment of changes
Diffstat (limited to 'src/example')
-rw-r--r--src/example/java/bjc/functypes/FixpointExample.java37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/example/java/bjc/functypes/FixpointExample.java b/src/example/java/bjc/functypes/FixpointExample.java
index 8d3e658..71dab4a 100644
--- a/src/example/java/bjc/functypes/FixpointExample.java
+++ b/src/example/java/bjc/functypes/FixpointExample.java
@@ -1,17 +1,28 @@
package bjc.functypes;
+import static bjc.functypes.Combinators.*;
+
import java.util.function.*;
-public class FixpointExample {
- public static void main(String[] args) {
- BiFunction<Integer, Function<Integer, Integer>, Integer> func
- = (input, self) -> {
- if (input <= 1) return 1;
- else return input * self.apply(input - 1);
- };
-
- Function<Integer, Integer> factorial = Fixpoints.fix(func);
-
- for (int i = 0; i < 10; i++) System.out.println(factorial.apply(i));
- }
-}
+/**
+ * Examples about how fixpoints work.
+ *
+ * @author Ben Culkin
+ *
+ */
+public class FixpointExample
+{
+ /**
+ * Main method.
+ *
+ * @param args Unused CLI args.
+ */
+ public static void main(String[] args) {
+ Function<Integer, Integer> factorial = Fixpoints.fix((input, self) -> {
+ if (input <= 1) return 1;
+ else return input * self.apply(input - 1);
+ });
+
+ times(10, andThen(factorial::apply, System.out::println));
+ }
+} \ No newline at end of file