Prelude API
    Preparing search index...

    Function sortedDiff

    • Returns a generator that compares two sorted iterables and yields tuples of corresponding elements. For matched elements, yields [lhs, rhs]. For elements only in lhs, yields [lhs, undefined]. For elements only in rhs, yields [undefined, rhs].

      Type Parameters

      • Lhs

        The type of left-hand side elements

      • Rhs

        The type of right-hand side elements

      Parameters

      • rhsValues: Iterable<Rhs>

        The right-hand side iterable (must be sorted)

      • cmp: (lhs: Lhs, rhs: Rhs) => number

        The comparison function for comparing lhs and rhs elements (any negative/zero/positive result, e.g. a - b)

      • direction: Cmp.R = Cmp.asc

        The direction of comparison (ascending by default)

      Returns (lhsValues: Iterable<Lhs>) => Generator<[lhs: Lhs, rhs: Rhs]>

      Tuples of corresponding elements from both iterables

      diff for a version that doesn't require presorted inputs

      G.pipe(
      [1, 3, 5],
      G.sortedDiff([2, 3, 4], (a, b) => a - b),
      G.array
      ) // [[1, undefined], [undefined, 2], [3, 3], [undefined, 4], [5, undefined]]