title: Clojure , increment a counter
body: <p>I have a collection looking like this:</p>
  
  <pre><code>[({:customer_id "111", :product_id "222"})({:customer_id "333", :product_id "444"}{:customer_id "555", :product_id "666"})...]
  </code></pre>
  
  <p>And i would like to flag the "position" of the hash in the collection. At the end i would like  my hash to look like this:</p>
  
  <pre><code>[({:product_id "222", :number "1"})({:product_id "444", :number "1"}{:product_id "666", :number "2"})...]
  </code></pre>
  
  <p>I'have try like this:</p>
  
  <pre><code>(-&gt;&gt; (pig/load-clj "resources/test0_file")
  (pig/map
       (fn [ord]
         (for [{:keys [product_id]} ord]
           (let [nb (swap! (atom 0) inc)]
             {:product_id product_id :number nb})))) 
  </code></pre>
  
  <p>But in that case nb is not incrementing. Thanks for you help</p>