This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-16
Channels
- # adventofcode (43)
- # announcements (31)
- # aws (2)
- # babashka (58)
- # babashka-sci-dev (4)
- # beginners (107)
- # calva (11)
- # cider (25)
- # clj-commons (8)
- # clj-kondo (24)
- # clojure (35)
- # clojure-argentina (1)
- # clojure-europe (25)
- # clojure-italy (5)
- # clojure-nl (11)
- # clojure-norway (39)
- # clojure-spec (11)
- # clojure-uk (3)
- # conjure (2)
- # core-async (19)
- # cursive (33)
- # data-science (2)
- # datomic (50)
- # deps-new (1)
- # emacs (3)
- # events (4)
- # figwheel-main (10)
- # fulcro (63)
- # graalvm (7)
- # holy-lambda (17)
- # introduce-yourself (1)
- # java (15)
- # jobs (1)
- # jobs-discuss (7)
- # malli (24)
- # meander (16)
- # nextjournal (19)
- # off-topic (2)
- # polylith (4)
- # portal (10)
- # re-frame (3)
- # reagent (19)
- # reitit (14)
- # releases (2)
- # remote-jobs (1)
- # reveal (19)
- # shadow-cljs (1)
- # sql (21)
- # testing (4)
- # xtdb (22)
can I set the paging limit for seqs in clerk
manually? I've got a rather large lazy sequence in a notebook that clerk seems to be a little too eager to print.
cartesian product. not nested, just very long.
if the sequence is lazy and uncounted, https://github.com/nextjournal/clerk/blob/main/src/nextjournal/clerk/config.clj#L13 should help you
correct - v`0.4.305`. this approximation isn't quite as slow as the actual dataset I'm encountering problems with, but it does demonstrate that rebinding *bounded-count-limit*
doesn't appear to limit the number of results it says are there (I'm still seeing "10M+ more..."). My expectation is that rebinding that var gives the printer a lower estimate of how much of the value to consume, but would the binding affect what happens on the "client side" (e.g. SCI/the browser context)?
(require '[clojure.math.combinatorics :as combo])
(binding [nextjournal.clerk.config/*bounded-count-limit* 500]
(def long-sequence
(->> (range 2 18)
(map #(range 1 %))
(apply combo/cartesian-product)
(map #(map (fn [v] (if (odd? v) (inc v) v)) %))
)))
this value will only affect caching, but not what gets send the to browser. The browser will only receive a tiny preview (first 20 elements)
if you want to affect the counting, binding
doesn’t work because after we eval the binding is reset to it’s root value, but alter-var-root
works:
but in your case the bounded-count with 1_000_000 seems fine? Clerk isn’t trying to print the whole thing, only does a bounded count…
my real case has a more expensive map fn than the repro, so a 1M bounded count is pretty slow for me (perhaps that means I should be trying to speed up my function instead of trying to curtail the clerk
printer 😉). thanks for following up.
maybe also consider just using (take)
to bound how much of the seq gets realized 🙂 one of the nice things about Clerk is that you have all your usual Clojure techniques with you, so they just transfer to these situations
the issue is that it tries to print a def
'd var that points to the sequence, forcing (some) realization at the point of definition when I would prefer to defer evaluation