Prelude API
    Preparing search index...

    Function recursive

    • Creates a generator by recursively applying a function to generate the next value. Continues until the done predicate function returns true.

      Type Parameters

      • T

        Element type

      Parameters

      • next: (value: T, index: number) => T

        Function that computes the next value based on current value and index

      • value: T

        Initial value

      • done: (value: T, index: number, previousValue: T | undefined) => boolean = ...

        Optional predicate function that determines when to stop (default: never stop)

      Returns Generator<T>

      Values produced by repeatedly applying the next function

      G.pipe(
      G.recursive(n => n * 2, 1, (n) => n > 16),
      G.array
      ) // [1, 2, 4, 8, 16]