For example:
a=[-5,-3,-1,1,3,5]
I want to find a negative and a positive minimum.
example: negative
print(min(a)) = -5
positive
print(min(a)) = 1
Using functools.reduce
>>> from functools import reduce
>>> a = [-5,-3,-1,2,3,5]
>>> reduce(lambda x,y: x if 0 <= x <=y else y if y>=0 else 0, a)
2
>>> min(a)
-5
>>>
Note: This will return 0 if there are no numbers >= 0 in the list.
reduce for functools looks like an overkill =)