Prelude API
    Preparing search index...

    Function rotate

    • Creates a generator that rotates elements in an iterable by n positions. Positive values rotate forward, negative values rotate backward.

      Type Parameters

      • T

        Element type

      Parameters

      • n: number

        Number of positions to rotate (positive for forward, negative for backward)

      Returns (g: Iterable<T>) => Generator<T>

      If n is not a safe integer

      Elements from the input iterable rotated by n positions

      G.pipe(
      G.range(1, 5),
      G.rotate(2),
      G.array
      ) // [3, 4, 5, 1, 2]