Skip to content

Commit

Permalink
Don't delay computations on +: and :+
Browse files Browse the repository at this point in the history
  • Loading branch information
jcazevedo committed Nov 28, 2022
1 parent 65b8ab3 commit 9417117
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/net/jcazevedo/phalanges/FingerTree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sealed abstract class FingerTree[V, A](implicit measured: Measured[A, V]) {
one = (_, b) => FingerTree.deep(Digit(a, b), m, sf),
two = (_, b, c) => FingerTree.deep(Digit(a, b, c), m, sf),
three = (_, b, c, d) => FingerTree.deep(Digit(a, b, c, d), m, sf),
four = (_, b, c, d, e) => FingerTree.deep(Digit(a, b), m.flatMap(ft => Lazy.delay(Node(c, d, e) +: ft)), sf)
four = (_, b, c, d, e) => FingerTree.deep(Digit(a, b), m.map(ft => Node(c, d, e) +: ft), sf)
)
)

Expand All @@ -54,7 +54,7 @@ sealed abstract class FingerTree[V, A](implicit measured: Measured[A, V]) {
one = (_, b) => FingerTree.deep(pr, m, Digit(b, a)),
two = (_, c, b) => FingerTree.deep(pr, m, Digit(c, b, a)),
three = (_, d, c, b) => FingerTree.deep(pr, m, Digit(d, c, b, a)),
four = (_, e, d, c, b) => FingerTree.deep(pr, m.flatMap(ft => Lazy.delay(ft :+ Node(e, d, c))), Digit(b, a))
four = (_, e, d, c, b) => FingerTree.deep(pr, m.map(ft => ft :+ Node(e, d, c)), Digit(b, a))
)
)

Expand Down

0 comments on commit 9417117

Please sign in to comment.