I have a foreach function that calls the specified function for each element it contains. I want to get the minimum from these elements, but I have no idea how to write a lambda or function, or even a class that can handle this. Thanks for any help.
I use the foreach function as follows:o.foreach( lambda i: i.call() )
or
o.foreach( I.call )
I do not like creating lists or other objects. I want to repeat it and find the mines.
I manage to write a class that thinks, but there must be some better solution than this:
class Min:
def __init__(self,i):
self.i = i
def get_min(self):
return self.i
def set_val(self,o):
if o.val < self.i: self.i = o.val
m = Min( xmin )
self.foreach( m.set_val )
xmin = m.get_min()
Ok, so I believe my .foreach method is an idea other than python. I have to make my class iterable, because all your decisions are list-based, and then everything will become easier.
# -, , , python .