Scoop API

scoop:scoop.std:0.1.0

scoop.sequences

API

  • interface Sequence

    A lazy source of iterators. Operations run when consumed; iterator-backed sequences permit only one traversal, while replay depends on the original source.

  • function all

    Consumes this sequence. Returns whether every element satisfies the predicate; true for empty input.

  • function any

    Consumes this sequence. Returns whether any eligible element exists, applying the predicate when supplied and stopping at the first match.

  • function asSequence

    Adapts the receiver without copying. Iterable receivers create a traversal each time; an Iterator receiver permits exactly one traversal.

  • function associate

    Consumes this sequence. Builds a map from transformed key-value pairs; later values replace earlier values for equal keys.

  • function associateBy

    Consumes this sequence. Builds a map using selected keys and optional value transformation; the last value for each key wins.

  • function associateWith

    Consumes this sequence. Associates each element with its selected value; later equal elements replace the stored value.

  • function chunked

    Evaluation is deferred until iteration. Partitions input into copied, nonoverlapping chunks of positive size; the final chunk may be shorter.

  • function contains

    Consumes this sequence. Stops at the first equal element and reports whether one exists.

  • function count

    Consumes this sequence. Counts eligible elements, applying the predicate when supplied.

  • function distinct

    Evaluation is deferred until iteration. Retains the first occurrence of each equal element in a lazy sequence.

  • function distinctBy

    Evaluation is deferred until iteration. Retains the first element for each selected key in a lazy sequence, preserving encounter order.

  • function drop

    Evaluation is deferred until iteration. Skips the first nonnegative count and copies the remainder into a lazy sequence.

  • function dropWhile

    Evaluation is deferred until iteration. Skips the initial run satisfying the predicate and copies the remainder.

  • function elementAt

    Consumes this sequence. Returns the element at a zero-based iteration index; an out-of-range index throws IndexOutOfBoundsException.

  • function elementAtOrNone

    Consumes this sequence. Returns the element at a zero-based iteration index, or None for a negative or out-of-range index.

  • function emptySequence

    Creates a repeatable sequence with no elements.

  • function filter

    Evaluation is deferred until iteration. Copies elements satisfying the predicate into a lazy sequence in iteration order.

  • function filterNot

    Evaluation is deferred until iteration. Copies elements failing the predicate into a lazy sequence in iteration order.

  • function filterNotNone

    Evaluation is deferred until iteration. Copies and unwraps Some elements into a lazy sequence, skipping None.

  • function filterTo

    Consumes this sequence. Appends matching elements to the destination and returns it.

  • function find

    Consumes this sequence. Returns the first element satisfying the predicate, or None.

  • function first

    Consumes this sequence. Returns the first eligible element in iteration order, applying the predicate when supplied; absence throws NoSuchElementException.

  • function firstOrNone

    Consumes this sequence. Returns the first eligible element in iteration order, applying the predicate when supplied, or None.

  • function flatMap

    Evaluation is deferred until iteration. Concatenates each transformed iterable into a lazy sequence in source order.

  • function flatMapTo

    Consumes this sequence. Appends each transformed iterable to the destination and returns it.

  • function flatten

    Evaluation is deferred until iteration. Concatenates the nested iterables into a lazy sequence in outer and inner iteration order.

  • function fold

    Consumes this sequence. Accumulates left to right from the supplied initial value, which is returned for empty input.

  • function forEach

    Consumes this sequence. Runs the action for each element in iteration order.

  • function forEachIndexed

    Consumes this sequence. Runs the action with each element and its zero-based Long index.

  • function generateSequence

    Generates values until the producer returns None. The producer-only overload is one-shot; the seed overload starts a fresh traversal from its seed.

  • function groupBy

    Consumes this sequence. Groups values into lists by the selected key, retaining encounter order within each group.

  • function groupByTo

    Consumes this sequence. Appends values into the destination's per-key mutable lists and returns that destination.

  • function indexOf

    Consumes this sequence. Returns the first equal element's zero-based iteration index, or -1 if absent.

  • function joinToString

    Consumes this sequence. Joins rendered elements with separator, prefix, and postfix. A nonnegative limit bounds rendered elements and appends truncated text when more remain.

  • function last

    Consumes this sequence. Returns the last eligible element after traversal, applying the predicate when supplied; absence throws NoSuchElementException.

  • function lastOrNone

    Consumes this sequence. Returns the last eligible element after traversal, applying the predicate when supplied, or None.

  • function map

    Evaluation is deferred until iteration. Transforms each element into a lazy sequence in iteration order.

  • function mapIndexed

    Evaluation is deferred until iteration. Transforms each element with its zero-based Long index into a lazy sequence.

  • function mapNotNone

    Evaluation is deferred until iteration. Transforms each element, retaining and unwrapping only Some results in a lazy sequence.

  • function mapTo

    Consumes this sequence. Appends transformed elements to the destination and returns it.

  • function maxOrNone

    Consumes this sequence. Traverses the input for its greatest element in natural order, returning None when empty.

  • function maxWithOrNone

    Consumes this sequence. Traverses the input for its greatest element under the comparator, returning None when empty.

  • function minOrNone

    Consumes this sequence. Traverses the input for its least element in natural order, returning None when empty.

  • function minWithOrNone

    Consumes this sequence. Traverses the input for its least element under the comparator, returning None when empty.

  • function none

    Consumes this sequence. Returns whether no eligible element exists, applying the predicate when supplied and stopping at the first match.

  • function onEach

    Evaluation is deferred until iteration. Runs the action for each element as it is consumed and yields that same element.

  • function partition

    Consumes this sequence. Returns two lists: matching elements first and nonmatching elements second, each retaining source order.

  • function random

    Consumes this sequence. Selects one element using the supplied random source; empty input throws NoSuchElementException.

  • function randomOrNone

    Consumes this sequence. Selects one element using the supplied random source, or returns None for empty input.

  • function reduce

    Consumes this sequence. Accumulates left to right from the first element; empty input throws NoSuchElementException.

  • function reduceOrNone

    Consumes this sequence. Accumulates left to right from the first element, or returns None for empty input.

  • function reversed

    Consumes this sequence. Returns an independent list in reverse iteration order.

  • function sequenceOf

    Creates a sequence over the supplied arguments in order.

  • function shuffled

    Evaluation is deferred until iteration. Copies the elements into a randomly permuted traversal using the supplied random source. Each traversal materializes the complete input before yielding results.

  • function single

    Consumes this sequence. Requires exactly one eligible element. No match throws NoSuchElementException; multiple matches throw IllegalArgumentException.

  • function singleOrNone

    Consumes this sequence. Returns the sole eligible element, or None for zero or multiple matches.

  • function sorted

    Evaluation is deferred until iteration. Creates a lazy sequence that materializes a stable copy in natural ascending order. Each traversal materializes the complete input before yielding results.

  • function sortedBy

    Evaluation is deferred until iteration. Creates a lazy sequence that materializes a stable copy ordered by the selector's natural key order. Each traversal materializes the complete input before yielding results.

  • function sortedDescending

    Evaluation is deferred until iteration. Creates a lazy sequence that materializes a stable copy in natural descending order. Each traversal materializes the complete input before yielding results.

  • function sortedWith

    Evaluation is deferred until iteration. Creates a lazy sequence that materializes a stable sorted copy using the supplied comparator. Each traversal materializes the complete input before yielding results.

  • function take

    Evaluation is deferred until iteration. Copies at most the first nonnegative count of elements into a lazy sequence.

  • function takeWhile

    Evaluation is deferred until iteration. Copies the longest initial run satisfying the predicate.

  • function toCollection

    Consumes this sequence. Adds all source elements to the destination and returns it.

  • function toList

    Consumes this sequence. Copies elements in encounter order into a read-only list.

  • function toMap

    Consumes this sequence. Copies associations into a read-only map; later values for equal keys win.

  • function toMutableList

    Consumes this sequence. Copies elements in encounter order into a new mutable list.

  • function toMutableMap

    Consumes this sequence. Copies associations into a new mutable map; later values for equal keys win.

  • function toMutableSet

    Consumes this sequence. Copies distinct elements into a new mutable insertion-ordered set.

  • function toSet

    Consumes this sequence. Copies distinct elements into a read-only set in first-encounter order.

  • function windowed

    Evaluation is deferred until iteration. Produces copied windows at the requested step. Size and step must be positive; incomplete trailing windows are included only when partialWindows is true.

  • function withIndex

    Evaluation is deferred until iteration. Pairs each element with its zero-based Long index as it is iterated.

  • function zip

    Evaluation is deferred until iteration. Pairs elements by position, stopping when either input ends.