title: Map function to an element in tuple
body: <p>I have in mind something that I would do in Haskell like this:</p>
  
  <pre><code>f :: Int -&gt; (Int, Int)
  -- for example:
  f = `divMod` 12
  foo :: [Int] -&gt; (Int, Int)
  foo = map (fmap (+1) . f)
  -- foo [10, 11, 12, 13] = [(0,11),(0,12),(1,1),(1,2)]
  </code></pre>
  
  <p>Is it possible to do such mapping to tuple in Python elegantly (without looking inside <code>f</code>?) The best I could come with was:</p>
  
  <pre><code>def foo(lst):
    for x in lst:
      a, b = f(x)
      yield a, b + 1
  </code></pre>
  
  <p>another possibility is</p>
  
  <pre><code>def foo(lst):
    return map(lambda x: (f(x)[0], f(x)[1]+1), lst)
  </code></pre>
  
  <p>But I like neither solution. I do not like the first one, because it's not a single expression and could not be so easily inlined. The other solution has this property, however it's ugly because it unnecessarily calls <code>f()</code> twice in each iteration. Is it possible to somehow unpack the result inside the iteration?</p>