title: Currying subtraction
body: <p>If we want to map a function that increases every element of a range by 1, we could write</p>
  
  <pre><code>map (\x -&gt; x + 1) [1..5]
  </code></pre>
  
  <p>but I guess most people would just go for</p>
  
  <pre><code>map (+1) [1..5]
  </code></pre>
  
  <p>instead. But this obviously doesn't work with (-1) since that's negative one.</p>
  
  <p>So the first thing that came to mind was </p>
  
  <pre><code>map (+(-1)) [1..5]
  </code></pre>
  
  <p>which would make sense considering how subtraction is defined in the Prelude (<code>x - y               = x + negate y</code>), but looks a bit odd to me. I then I came up with </p>
  
  <pre><code>map (flip (-) 1) [1..5]
  </code></pre>
  
  <p>This somehow looks better to me, but is maybe a bit too complicated.</p>
  
  <p>Now I know this no big deal, but I'm wondering if I'm missing a more obvious way to write this? If not, which of the 2 ways would you prefer? I'm really just asking because often it's small details like this that make your code more idiomatic and hence pleasant for other developers who have to read it. </p>
  
  <p><strong>Solution</strong></p>
  
  <p>Now that I got a couple of answers, I think my personal favorite is</p>
  
  <pre><code>map (subtract 1) [1..5]
  </code></pre>
  
  <p>followed by</p>
  
  <pre><code>map pred [1..5]
  </code></pre>
  
  <p>mostly because the first one is really explicit and nobody needs to guess/look up what <code>pred</code> means (predecessor). </p>