title: Python, lambda, find minimum
body: <p>I have foreach function which calls specified function on every element which it contains. I want to get minimum from thise elements but I have no idea how to write lambda or function or even a class that would manage that.
  Thanks for every help.
  <hr>
  I use my foreach function like this:</p>
  
  <pre><code>o.foreach( lambda i: i.call() )
  </code></pre>
  
  <p>or</p>
  
  <pre><code>o.foreach( I.call )
  </code></pre>
  
  <p>I don't like to make a lists or other objects. I want to iterate trough it and find min.</p>
  
  <p>I manage to write a class that do the think but there should be some better solution than that:</p>
  
  <pre><code>class Min:                                           
      def __init__(self,i):                        
          self.i = i                              
      def get_min(self):                               
          return self.i                                
      def set_val(self,o):                             
          if o.val &lt; self.i: self.i = o.val
  
  m = Min( xmin )
  self.foreach( m.set_val )                            
  xmin = m.get_min()
  </code></pre>
  
  <hr>
  
  <p>Ok, so I suppose that my .foreach method is non-python idea. I should do my Class iterable because all your solutions are based on lists and then everything will become easier.</p>
  
  <p>In C# there would be no problem with lambda function like that, so I though that python is also that powerful.</p>