Which are the differences between scan
and scanLeft
?
For instance,
(1 to 3).scan(10)(_-_)
res: Vector(10, 9, 7, 4)
(1 to 3).scanLeft(10)(_-_)
res: Vector(10, 9, 7, 4)
deliver the same result, clearly in contrast to
(1 to 3).scanRight(10)(_-_)
res: Vector(-8, 9, -7, 10)
(1 to 3).par.scanLeft(10)(_-_)
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(10, 9, 7, 4)
(1 to 3).par.scanRight(10)(_-_)
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(-8, 9, -7, 10)
(1 to 3).par.scan(10)(_-_)
res: scala.collection.parallel.immutable.ParSeq[Int] = ParVector(10, 9, -1, -4)
Basically, it depends on the implementation of the traversable of how scan*
(or fold*
) is executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With