Enumerable Min - FireDragon91245/Lua-Linq GitHub Wiki

enumerable:min

Returns the smallest item or projected value. You can use a selector and optionally a custom comparison rule.

Overloads

enumerable<T>   :min():                                  T
enumerable<K, V>:min():                                  V

enumerable<T>   :min(selector: fun(item: T): R):         R
enumerable<K, V>:min(selector: fun(key: K, value: V): R): R

enumerable<T>   :min(selector: string):                  any
enumerable<K, V>:min(selector: string):                  any

enumerable<T>   :min(
    selector:   fun(item: T): R,
    is_smaller: fun(a: R, b: R): boolean
): R
enumerable<K, V>:min(
    selector:   fun(key: K, value: V): R,
    is_smaller: fun(a: R, b: R): boolean
): R

enumerable<T>   :min(
    selector:   string,
    is_smaller: fun(a: any, b: any): boolean
): any
enumerable<K, V>:min(
    selector:   string,
    is_smaller: fun(a: any, b: any): boolean
): any

enumerable<T>   :min(
    selector:   fun(item: T): R,
    is_smaller: string
): R
enumerable<K, V>:min(
    selector:   fun(key: K, value: V): R,
    is_smaller: string
): R

enumerable<T>   :min(
    selector:   string,
    is_smaller: string
): any
enumerable<K, V>:min(
    selector:   string,
    is_smaller: string
): any
  • selector: string acts as a key/property selector when it does not contain =>. If it contains => it is treated as a lambda expression.

Examples

local smallest = linq.list(4, 12, 7):min()
local cheapest = linq.list({ price = 40 }, { price = 12 }, { price = 25 })
    :min("price")
⚠️ **GitHub.com Fallback** ⚠️