@mirei/ts-collections
    Preparing search index...

    Function infiniteSequence

    • Generates an infinite numeric sequence starting from the specified value with the given step increment.

      Parameters

      • start: number

        Initial value of the sequence.

      • step: number

        Step size to increment each subsequent value.

      Returns IEnumerable<number>

      An infinite sequence of numbers starting from start, incremented by step for each subsequent element.

      Enumeration is deferred and will continue indefinitely unless limited by operations like take or takeWhile. The sequence can be ascending (positive step) or descending (negative step).

      const ascending = infiniteSequence(1, 1).take(5).toArray();
      console.log(ascending); // [1, 2, 3, 4, 5]
      const descending = infiniteSequence(10, -1).take(5).toArray();
      console.log(descending); // [10, 9, 8, 7, 6]
      const stepped = infiniteSequence(0, 2).take(5).toArray();
      console.log(stepped); // [0, 2, 4, 6, 8]