Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » maxPosition
next | previous | forward | backward | up | index | toc

# maxPosition -- position of the largest element

- Usage:
    `maxPosition L`
- Inputs:
  - L, a basic list,
- Outputs:
  - i, an integer, the index of the largest element in the list L

## Description

If the largest element occurs more than once, the index of its first occurrence is used.

    i1 : maxPosition {1, 6, 4, 2, 6}

    o1 = 1

If L contains elements in a polynomial ring, the MonomialOrder of the ring is used for comparisons.

    i2 : R1 = QQ[x, y, z, MonomialOrder => Lex];

    i3 : maxPosition {x*y^2, x*y^2 + z^2, y^4, y*z^5}

    o3 = 1

    i4 : R2 = QQ[x, y, z, MonomialOrder => GRevLex];

    i5 : maxPosition (x*y^2, x*y^2 + z^2, y^4, y*z^5)

    o5 = 3

More generally, the order of the elements is determined using the ? operator.

## See also

- minPosition -- position of the smallest element
- max -- get the maximum element in a list or sequence
- min -- get the minimum element in a list or sequence
- sort -- sort a list or columns of a matrix
- position -- the first element of a list satisfying a condition
- positions -- which elements of a list satisfy a condition
- ? -- comparison operator

## Ways to use maxPosition:

- `maxPosition(BasicList)`

## For the programmer

The object maxPosition is a method function with a single argument.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/maxPosition-doc.m2:41:0.