title: If condition in map function
body: <p>Is there a way to check for a condition in a map function in scala? I have this list for example:</p>
  
  <pre><code>List(1,2,3,4,5,6)
  </code></pre>
  
  <p>and I want all the even numbers to be mulitplied by 2 and all the odd numbers to be divided by 2.</p>
  
  <p>Now in python this would look something like this:</p>
  
  <pre><code>map(lambda x: 2*x if x % 2 == 0 else x/2, l)
  </code></pre>
  
  <p>Is there a way to do that in Scala?</p>