title: For loop as an input parameter of a function in python
body: <p>I am trying to understand solving Sudoku in Python from <a href="http://norvig.com/sudoku.html" rel="nofollow">this</a> website. I couldn't understand the "Search" Function in particular the application of "some" function in the "search".</p>
  
  <pre><code>def search(values):
  "Using depth-first search and propagation, try all possible values."
  if values is False:
      return False ## Failed earlier
  if all(len(values[s]) == 1 for s in squares): 
      return values ## Solved!
  ## Chose the unfilled square s with the fewest possibilities
  n,s = min((len(values[s]), s) for s in squares if len(values[s]) &gt; 1)
  return some(search(assign(values.copy(), s, d)) 
      for d in values[s])
  
  def some(seq):
      "Return some element of seq that is true."
      for e in seq:
          if e: return e
      return False
  </code></pre>
  
  <p><code>values</code> which is the input of the <code>search</code> is a dictionary (key: name of each square, value: string of possible values for that square). In the <code>search</code> we try to find one square( a square is a place holder of one number in Sudoku) which has the least number of possible values to fill. Then, the <code>assign</code> function is called for each of that values. the output of <code>assign</code> can be <code>false</code> or can be the new dictionary <code>values</code>. I am wondering what is the purpose of "some" function here? </p>