@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function diff_right

    • compute the right-to-left (ie reverse) running difference between preceding elements.

      the returned array's length is decremented by one. as a result, a single element array will turn into an empty array.

      Note

      be careful when using with unsigned typed arrays.

      Type Parameters

      Parameters

      • arr: A
      • Optionalstart: number
      • Optionalend: number

      Returns A

      import { assertEquals } from "jsr:@std/assert"

      // basic example
      const arr1 = [1, 2, 3, 4, 5, 99, 88]
      const arr1_diff = diff_right(arr1)
      assertEquals(arr1_diff, [-1, -1, -1, -1, -94, 11])

      // subarray slicing example
      const arr2 = [1, 2, 3, 4, 5, 99, 88]
      const arr2_diff = diff_right(arr2, 2, -1)
      assertEquals(arr2_diff, [-1, -1, -94])