Fork me on GitHub
Jeff Evans22:01:12

why is this not being lazy? (this is for day 15, part 1)

(defn get-spoken-num [accumulator number last-val]
    (let [last-seen (get accumulator last-val)
          last-round-num (dec number)
          seen-before? (and (some? last-seen) (< last-seen last-round-num))
          this-round (if seen-before? (- last-round-num last-seen) 0)]
          (assoc accumulator this-round number) 
          (inc number) 

Jeff Evans22:01:08

hmm, actually maybe it is ( take 10 (…) works fine). I guess evaluating the full lazy sequence in the REPL actually traverses it