kumulant

RunLengthResult

@Serializable
@SerialName(value = "RunLengthResult")
data class RunLengthResult(val current: Long, val longest: Long, val leading: Long = current, val anyFalsy: Boolean = false) : Result(source)

Current and longest consecutive truthy-run lengths.

Constructors

RunLengthResult

constructor(current: Long, longest: Long, leading: Long = current, anyFalsy: Boolean = false)(source)

Properties

anyFalsy

False while the stream has been one unbroken run, i.e. leading covers all of it.

Needed because concatenation only extends the leading and trailing runs through a stream that never broke; otherwise they are pinned by the falsy value that broke it.

current

Length of the current run; reset to zero when the input was last falsy.

leading

Length of the run this stream opened with, before its first falsy value.

Only RunLengthStat.merge needs it, and it is what makes that merge correct: concatenating two streams can create a run spanning the join, whose length is the left stream's trailing run plus the right stream's leading one.

longest

Longest run observed so far.