title: Clojure - Adding pairs of numbers in a vector
body: <p>I have a vector <code>[1 2 3 4]</code>. Is there a way of adding each pair to get <code>[(+ 1 2) (+ 2 3) (+ 3 4)]</code></p>
  
  <p>I tried </p>
  
  <pre><code>(loop [x 0] 
    (when (&lt; x (count y)) 
      (+ (nth y x) (nth y (+ 1 x))) 
      (recur (+ x 1))))
  </code></pre>
  
  <p>But I get an out of bounds error <code>IndexOutOfBoundsException   clojure.lang.PersistentVector.arrayFor (PersistentVector.java:158)</code></p>