This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-14
Channels
- # adventofcode (2)
- # announcements (61)
- # babashka (26)
- # beginners (125)
- # calva (63)
- # cider (33)
- # clj-kondo (40)
- # cljs-dev (24)
- # clojure (165)
- # clojure-australia (8)
- # clojure-dev (4)
- # clojure-europe (44)
- # clojure-finland (1)
- # clojure-greece (4)
- # clojure-losangeles (1)
- # clojure-nl (28)
- # clojure-taiwan (3)
- # clojure-uk (64)
- # clojurescript (2)
- # core-async (14)
- # datomic (34)
- # docker (2)
- # fulcro (9)
- # garden (1)
- # jobs (4)
- # jobs-discuss (21)
- # kaocha (3)
- # off-topic (48)
- # pathom (4)
- # practicalli (3)
- # remote-jobs (3)
- # shadow-cljs (46)
- # spacemacs (6)
- # sql (4)
- # tools-deps (22)
- # xtdb (5)
- # yada (2)
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)))))
hmm, actually maybe it is ( take 10 (…)
works fine). I guess evaluating the full lazy sequence in the REPL actually traverses it