[top][index]
search for:

minPosition BasicList -- position of smallest element

Synopsis:

  • Usage: n = minPosition x
  • Function: minPosition -- position of smallest element
  • Input:
  • x, an instance of class BasicList.
  • Output:
  • n, an instance of class ZZ: the position of the smallest element in the list x.
  • If the smallest element occurs more than once, then the first occurrence is used. If x has length 0 an error results.

    See also:

  • maxPosition BasicList -- position of largest element
  • Code:

         -- ../../../Macaulay2/m2/lists.m2:30-36
         minPosition BasicList := ZZ => x -> (
              if # x === 0 then error "expected a nonempty list" 
              else (
                   m := x#0; 
                   pos := 0;
                   scan(1 .. # x-1, i -> if x#i>m then (m=x#i;pos=i));
                   pos))

    [top][index]
    search for: