title: Clojure NullPointerException on for loop
body: <p>I'm about to pull out my hair on this one. </p>
  
  <p>For some context, I'm implementing a simple algorithm in Clojure. assume the following data structures</p>
  
  <pre><code>(def inf Double/POSITIVE_INFINITY)
  (def min-dist (atom {:1 {:1 0 :2 4} :2 {:1 4 :2 0 :3 5} :3 {:2 5 :3 0}}))
  (def vertexes [:1 :2 :3])
  </code></pre>
  
  <p>The following code will crash after the first iteration:</p>
  
  <pre><code>(for [k vertexes i vertexes j vertexes]
    ((println (str " " i " " k " "j))
     (if (&gt; (get-in @min-dist [i j] inf) (+ (get-in @min-dist [i k] inf) (get-in @min-dist [k j] inf)) )
       (do
         ;;do some stuff
         (println "bla"))
     )))
  </code></pre>
  
  <p>With the following output:</p>
  
  <blockquote>
    <p>:1 :1 :1 NullPointerException<br>
    user.core/eval7683/iter--7675--7684/fn--7685/iter--7677--7686/fn--7687/iter--7679--7688/fn--7689/fn--7690
    (form-init1244434853692676604.clj:2)</p>
  </blockquote>
  
  <p>I do understand that I'm probably violating some references during the <code>if</code> here. But I'm new to clojure and have no idea on what I'm doing wrong here. Something to do with the triple-for over the same seq?</p>