# max

Source: https://taxilang.org/docs/language/stdlib/max

**Full name:** `taxi.stdlib.max`

## Signature

```taxi
declare extension function <T,A> max(collection: T[], callback: (T) -> A):A
```

## Description

Returns the maximum value in the collection, computed by applying the selector function to each element.

```taxi
find { products: Product[] } as {
   mostExpensive: Price = products.max((Product) -> Price)
}
```

## Examples

Returns the maximum price from a collection of products.

Schema:

```taxi
model Product {
   name: String
   price: Price inherits Decimal
}
```

Query:

```taxi
given {
   products: Product[] = [
      { name: 'Apple', price: 1.50 },
      { name: 'Banana', price: 0.75 },
      { name: 'Cherry', price: 3.00 }
   ]
}
find {
   maxPrice: Price = products.max((Product) -> Price)
}
```

Result:

```json
{
  "maxPrice": 3
}
```
