From 5e26c7cb3ab8524efde41b00affdaa17f9874a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20L=C3=A4ufer?= Date: Sun, 17 Dec 2023 13:19:37 -0600 Subject: [PATCH] added worksheet for further explorations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Konstantin Läufer --- src/test/scala/Explorations.sc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/test/scala/Explorations.sc diff --git a/src/test/scala/Explorations.sc b/src/test/scala/Explorations.sc new file mode 100644 index 0000000..80963f3 --- /dev/null +++ b/src/test/scala/Explorations.sc @@ -0,0 +1,21 @@ +// iota(10) // => List(0,1,2,3,4,5,6,7,8,9,10) +// -- maybe I must use ana and coalgebra + +import higherkindness.droste._ +import higherkindness.droste.data._ +import higherkindness.droste.syntax.all + +def iota(n: Int) = Coalgebra[Option, Int]: + i => if i < n then Some(i + 1) else None + +// stack overflow +// scheme.ana(iota(1000000)).apply(0) + +val toInt = Algebra[Option, Int]: + case None => 0 + case Some(i) => i * i + 1 + +scheme.hylo(toInt, iota(10)).apply(7) + +//times("foo", 3) // => List("foo", "foo", "foo") +// -- maybe I must use ana, coalgebra, and the other thing \ No newline at end of file