FuncType - v0.9.5
    Preparing search index...

    Interface 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]
    interface LazyList<A extends Type> {
        _tag: "LazyList";
        "[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>;
        fold<B>(onEmpty: () => B, onValue: (value: A) => B): B;
        foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
        foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
        forEach(f: (a: A) => void): void;
        last(): Option<A>;
        map<B extends unknown>(f: (a: A) => B): LazyList<B>;
        pipe<U extends unknown>(f: (value: LazyList) => U): U;
        reduce<B extends unknown>(f: (acc: B, a: A) => B, initial: B): B;
        serialize(): SerializationMethods<LazyList<A>>;
        some(predicate: (a: A) => boolean): boolean;
        take(n: number): LazyList<A>;
        takeWhile(predicate: (a: A) => boolean): LazyList<A>;
        toArray(): A[];
        toList(): List<A>;
        toString(): string;
        zip<B extends unknown>(other: LazyList<B>): LazyList<[A, B]>;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    _tag: "LazyList"

    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>

    • Pattern matches over the structure, applying specific handlers for each variant

      Type Parameters

      • B

      Parameters

      • onEmpty: () => B

        Function to apply if the structure is empty or has no value

      • onValue: (value: A) => B

        Function to apply if the structure has a value

      Returns B

      The result of applying the appropriate function

    • Left-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (b: B, a: A) => B) => B

      A function that takes an operation to apply

    • Right-associative fold using the provided zero value and operation

      Type Parameters

      • B

      Parameters

      • z: B

        Zero/identity value

      Returns (op: (a: A, b: B) => B) => B

      A function that takes an operation to apply

    • Parameters

      • f: (a: A) => void

      Returns void

    • Type Parameters

      • B extends unknown

      Parameters

      • f: (a: A) => B

      Returns LazyList<B>

    • Pipes the value through the provided function

      Type Parameters

      • U extends unknown

        The return type of the function

      Parameters

      • f: (value: LazyList) => U

        The function to apply to the value

      Returns U

      The result of applying the function to the value

    • 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[]

    • Returns a string representation of an object.

      Returns string