Prelude API
    Preparing search index...

    Function maybeLast

    • Creates a function that returns the last element from an iterable or undefined if empty, with optional sorting. If a comparator is provided, sorts the values before returning the last element. Otherwise, returns the last element from the values in their original order.

      Type Parameters

      • T

      Parameters

      • Optionalcmp: Cmp.t<T, T>

        Optional comparator function to use for sorting

      Returns <U>(values: Iterable<U>) => T | undefined

      A function that takes an iterable and returns its last element or undefined if empty

      last for a variant that throws on empty iterables