def minimals(A, le=(lambda x, y: (x <= y))):
 r = []
 for x in A:
  for a in A:
   if (le(a, x) and (not le(x, a))):
    break
  else:
   for a in r:
    if le(a, x):
     break
   else:
    r.append(x)
 return r

def minimals ( A , le = ( lambda x , y : ( x <= y ) ) ) : r = [ ] for x in A : for a in A : if ( le ( a , x ) and ( not le ( x , a ) ) ) : break else : for a in r : if le ( a , x ) : break else : r . append ( x ) return r
find the minimal element(s) of a sequence of partially ordered elements .