This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-02
Channels
- # adventofcode (2)
- # bangalore-clj (1)
- # beginners (26)
- # boot (7)
- # cider (21)
- # clara (45)
- # cljs-dev (1)
- # cljsrn (2)
- # clojure (168)
- # clojure-berlin (1)
- # clojure-india (4)
- # clojure-italy (7)
- # clojure-nl (1)
- # clojure-russia (1)
- # clojure-spec (10)
- # clojure-uk (12)
- # clojurescript (31)
- # datascript (2)
- # datomic (28)
- # defnpodcast (9)
- # emacs (2)
- # events (4)
- # fulcro (193)
- # hoplon (127)
- # hypercrud (1)
- # jobs (1)
- # jobs-discuss (38)
- # keechma (1)
- # luminus (5)
- # off-topic (16)
- # onyx (4)
- # parinfer (9)
- # portkey (2)
- # portland-or (1)
- # precept (5)
- # re-frame (9)
- # reagent (8)
- # remote-jobs (7)
- # rum (3)
- # shadow-cljs (2)
- # spacemacs (19)
- # specter (2)
- # testing (1)
- # unrepl (34)
An interesting extra case in nth
, right before it resorts to linear-traversal-nth
, would be to check if it supports IReduce
and to get the n th value without forcing the collection being held by coll
to be realized. I think this is really only useful as a memory-perf optimization when using some of the newer directly reducible sequence generators on master. To do that would probably look like something along these lines:
(implements? IReduce coll)
(if (neg? n)
(throw (js/Error. "Index out of bounds"))
(transduce (drop n)
(fn ([z] (if (= z ::ioob) (throw (js/Error. "Index out of bounds")) z))
([_ x] (reduced x)))
::ioob coll))