Skip to content

Commit

Permalink
added worksheet for further explorations
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantin Läufer <[email protected]>
  • Loading branch information
klaeufer committed Dec 17, 2023
1 parent 04e0bc4 commit 5e26c7c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/scala/Explorations.sc
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e26c7c

Please sign in to comment.