adventofcode

Happy Advent 2020! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb
2021-01-14T22:40:12.000300Z

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

(defn get-spoken-num [accumulator number last-val]
  (lazy-seq
    (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)]
      (cons 
        this-round 
        (get-spoken-num
          (assoc accumulator this-round number) 
          (inc number) 
          this-round)))))

2021-01-14T22:41:08.000800Z

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