com.metamx.common.scala.collection
Chunk (un-flatten) objects greedily using an accumulator.
Chunk (un-flatten) objects greedily using an accumulator. When the continue-chunk condition returns false, the element for which it returned false will become the start of a new chunk. It will then be re-evaluated with a new accumulator. If this re-evaluation fails to return true, an exception will be thrown.
Example: xs.grouped(2) == xs.chunked(0)((a, _) => a + 1)(_ <= 2)
accumulator type
zero for the accumlator type
accumulation function
continue-chunk condition
chunked objects
For preserving laziness, e.
For preserving laziness, e.g.
Stream.fill(n) { ... } onComplete { ns => log.debug("Evaluation complete: %s", ns) }
Similar to takeWhile(!p), but include the last-tested element and don't evaluate beyond it:
Similar to takeWhile(!p), but include the last-tested element and don't evaluate beyond it:
Stream.from(0) map { x => assert(x < 3); x } takeUntil (_ == 2) toList --> List(0,1,2) Stream.from(0) map { x => assert(x < 3); x } takeWhile (_ < 3) toList --> assertion error: 3 < 3