title: How to perform operation on elements of list which depend on previous elements?
body: <p>Using map can do operations of current element in list:</p>
  
  <pre><code>l = [1,2,3,4,5,6];
  
  
  print(list(map(lambda x: x*2, l)))  
  # gives [2, 4, 6, 8, 10, 12]
  </code></pre>
  
  <p>In above, multiply by 2 is done for all elements in l. But how to mulitiply by 2 an element in l, only if previous value in l is odd? Can use map for this?</p>
  
  <p>For example to get:</p>
  
  <pre><code>[1,4,3,8,5,12] % only 2, 4 and 6 from l are multiplyied by 2, because before them there are odd numbers 1,3,5. 
  </code></pre>