def argmin(l):
    """
    Return the position of the minimal element in the list ``l``.

    EXAMPLES::

        sage: from surface_dynamics.misc.permutation import argmin
        sage: argmin([3,0,1,2])
        1
        sage: argmin([-1,3,5,-2,50])
        3
    """
    if not l:
        raise ValueError('empty list')
    imin = 0
    jmin = l[0]
    for i, j in enumerate(l):
        if j < jmin:
            jmin = j
            imin = i
    return imin
