FuncType - v0.8.85
    Preparing search index...

    Type Alias LazyList<A>

    LazyList provides lazy evaluation for list operations. Operations are deferred until the list is materialized.

    // Basic lazy evaluation
    const result = LazyList([1, 2, 3, 4, 5])
    .map(x => x * 2)
    .filter(x => x > 5)
    .toArray() // [6, 8, 10]
    // Infinite sequences with take
    const fibonacci = LazyList.iterate([0, 1], ([a, b]) => [b, a + b])
    .map(([a]) => a)
    .take(10)
    .toArray() // [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
    type LazyList<A extends Type> = {
        "[iterator]"(): Iterator<A>;
        concat(other: LazyList<A>): LazyList<A>;
        count(): number;
        drop(n: number): LazyList<A>;
        dropWhile(predicate: (a: A) => boolean): LazyList<A>;
        every(predicate: (a: A) => boolean): boolean;
        filter(predicate: (a: A) => boolean): LazyList<A>;
        find(predicate: (a: A) => boolean): Option<A>;
        first(): Option<A>;
        flatMap<B extends unknown>(f: (a: A) => LazyList<B>): LazyList<B>;
        forEach(f: (a: A) => void): void;
        last(): Option<A>;
        map<B extends unknown>(f: (a: A) => B): LazyList<B>;
        reduce<B extends unknown>(f: (acc: B, a: A) => B, initial: B): B;
        some(predicate: (a: A) => boolean): boolean;
        take(n: number): LazyList<A>;
        takeWhile(predicate: (a: A) => boolean): LazyList<A>;
        toArray(): A[];
        toList(): List<A>;
        zip<B extends unknown>(other: LazyList<B>): LazyList<[A, B]>;
    }

    Type Parameters

    Index

    Methods

    • Returns Iterator<A>

    • Returns number

    • Parameters

      • predicate: (a: A) => boolean

      Returns LazyList<A>

    • Parameters

      • predicate: (a: A) => boolean

      Returns boolean

    • Parameters

      • predicate: (a: A) => boolean

      Returns LazyList<A>

    • Parameters

      • predicate: (a: A) => boolean

      Returns Option<A>

    • Parameters

      • f: (a: A) => void

      Returns void

    • Type Parameters

      • B extends unknown

      Parameters

      • f: (a: A) => B

      Returns LazyList<B>

    • Type Parameters

      • B extends unknown

      Parameters

      • f: (acc: B, a: A) => B
      • initial: B

      Returns B

    • Parameters

      • predicate: (a: A) => boolean

      Returns boolean

    • Parameters

      • predicate: (a: A) => boolean

      Returns LazyList<A>

    • Returns A[]