This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-15
Channels
- # beginners (26)
- # biff (28)
- # calva (13)
- # clj-commons (4)
- # clj-kondo (3)
- # clojure (45)
- # clojure-austin (17)
- # clojure-europe (8)
- # clojure-finland (1)
- # clojurescript (14)
- # code-reviews (3)
- # emacs (33)
- # helix (4)
- # holy-lambda (7)
- # joyride (5)
- # keechma (1)
- # meander (4)
- # membrane (3)
- # missionary (22)
- # nbb (1)
- # off-topic (1)
- # pathom (4)
- # rdf (24)
- # releases (2)
- # sci (3)
- # shadow-cljs (12)
- # tools-deps (14)
is there an easy way to turn Java lang interable into a discrete flow or should I loop/recur and .next .hasNext
or, how to turn a slow lazy seq into discrete flow
(defn iterator-consumer [^java.util.Iterator iterator]
(m/ap
(while (m/?? (m/enumerate (when (m/? (m/via m/blk (.hasNext iterator))) [false true]))))
(.next iterator)))
(defn iterator-consumer [^java.util.Iterator iterator]
(m/ap
(loop []
(if (m/? (m/via m/blk (.hasNext iterator)))
(amb (.next iterator) (recur))
(amb)))))
?what if I have a slow lazy seq (attached to a database iterator)
cc/reduce inside an m/observe? using ! inside the reducing function to seed the stream
or just drop to low-level flow interface
use the blocking iterable pattern, replace hasNext with seq and next with first/rest
for the record
@U09K620SG out of curiosity - do you use your dustingetz.scratch
namespace in a mutable fashion?
I mean - do you have a static project you use for constant, minor experimentation stuff?
Asking because I haven't found a workflow that works for me for "small stuff". I end up either creating lots and lots of projects -- or I have a scratch
project that just accumulates so much cruft it gets slow and tedious, just adding more and more dependencies and namespaces.
i like a scratch folder and :scratch alias in every big project and i commit anything interesting. i have a default scratch file that is easy to open with the core project requires preset and then rename and commit if worth saving, otherwise discard changes
Interesting. That's really helpful. Thank you! I might steal your workflow. Separating :scratch out as it's own alias sounds like a very good idea to enable exploration + avoid accidents. I also suspect it can help encourage exploration - and sharing those explorations.