This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # aws (44)
- # beginners (96)
- # calva (10)
- # cider (7)
- # cljdoc (5)
- # cljsrn (2)
- # clojure (38)
- # clojure-dev (19)
- # clojure-europe (6)
- # clojure-italy (16)
- # clojure-nl (10)
- # clojure-norway (44)
- # clojure-spec (7)
- # clojure-uk (74)
- # clojurescript (133)
- # cloverage (1)
- # crux (11)
- # cursive (54)
- # datomic (78)
- # duct (11)
- # graalvm (5)
- # instaparse (4)
- # joker (3)
- # kaocha (5)
- # nrepl (2)
- # off-topic (10)
- # pathom (56)
- # pedestal (1)
- # reagent (7)
- # reitit (17)
- # shadow-cljs (144)
- # slack-help (2)
- # sql (35)
- # testing (5)
- # tools-deps (22)
- # vim (22)
doseq where I want a
nil i.e. pure effect, and an eager-like
for, i.e. nested iteration… guessing you mean
Ah I think we had a conversation about this the other day, quite a few different options depending on what you want to do
In which case it depends I think on whether you’re being given something that might be lazy… or if you’re in control and want something eager. I’d assume the later given your question. So if you have the control and want something eager, then you’re better creating it as such with either
into, a transducer, or
mapv — but also consider whether the datastructure is important.
So, let's say I'm slurping a json file and creating a map, inside that map there is a key with a vector (of strings). I want to hit an API with each string, one after the other, would you invoke that API via a mapv (passing in each string) or a doseq?
I’d probably use
run! in that case, because there are only side effects, the return value not used
run! was the one I found out about the other day when we were chatting about this, I’d always used
which is perferred, doseq or run! (I seem to recall, somewhere, can't remember, that
run! should be the first choice...can't remember the reasons)
run! if you’re mapping an effectful procedure you already have over a sequence you already have (sounds like you do).
(run! println (range 10))
(doseq [i (range 10)] (dosomething! i ,,,) (dosomething-else! i)))
(run! (fn [vin] (check-eligibility vin)) vins) works grand! (I'll probably use a function literal, just playing...)
but it’s not the end of the world if you pick either way — it’s totally fine… I’m splitting hairs somewhat.
A more important distinction is picking
doseq if you want
for-like comprehension behaviour.
I don't think I have ever used
run!. Somehow it is one of those core functions that I always forget even exists.
Honestly, if I found a magic lamp, I think my first wish would be to have a complete mental catalogue of the clojure core API 🙂
I’m going to echo @wesley.hall here, I don’t think I’ve ever used
run! to the point where I vaguely know what it does but can’t even remember the args >_<…
It was introduced in 1.7 without the kind of fanfare features like transducers got, so many old timers who learned core in the 1.0 days either missed it, or were stuck in their ways. And I think that meant a lot of more recent entries to the community missed it too — as a lot of tutorials etc will use
What is a bit confusing (for me at least!) is that in the
run! docs, it says
runs the supplied procedure, shouldn't it be
runs the supplied function. I'm always thinking
ARe you planning on packaging your wishes up as a lazy sequence to get by the “you can’t wish for more wishes” rule
@dharrigan That might be a subtle nod to the fact that you don't care about / wont get the return value. "Function" implies input / output, I guess "procedure" describes a side-effect 'function'.
@dharrigan an async viewpoint - for an api or other i/o op, and if you are using async i/o, you can do something somewhat different - and use a graph of (core.async) channels or (manifold) streams
stream<op-metadata> ==> stream<promise<op-result>> ==> buffered-stream<promise<op-result>> ==> stream<op-result> and then you can use the size of the buffer to control concurrency (with backpressure)
in manifold terms this looks like
(->> ops (s/map do-async-op-io) (s/buffer N) (s/realize-each) (s/reduce conj ))
shout out to the collective wisdom - does anyone know of a linux (arch) utility that when fed a string (or some stdin), that it will display on the terminal in big bold letters (configurable) and a red line surrounding (configurable) the stdin - if you recall the guru meditation on amigas, you know what I mean 🙂
toilet -F border will put a simple border around the text
-f term will just use regular letters rather than fancy figlet fonts
They have their place. Didn't think that's what you were going for with a guru meditation though 🙂
There was some interest in Clojure and Graal previously, eg. compiling JVM languages to native images, fast startup time, etc. Is there still interested in London Clojurians event on Graal?
One of the developers at Oracle is interested in doing a talk or workshop with the Clojure community in London. What sort of things would you find interesting??
Its interesting to see projects such as clj-kondo using Graal to help distribute to different platforms. I havent looked into the detail, but it seem to give Clojure more reach...
@borkdude will do. Just curious, do you use GraalVM native images to help startup time for clj-kondo ? I though you might be, but not 100% sure.
@jr0cket I think the native-image stuff has been talked to death. But the multi language features seem to have been under explored imo.