This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-07
Channels
- # beginners (4)
- # boot (186)
- # cider (68)
- # cljsjs (2)
- # cljsrn (6)
- # clojure (103)
- # clojure-dev (1)
- # clojure-russia (117)
- # clojurescript (40)
- # community-development (31)
- # cursive (2)
- # data-science (7)
- # datomic (6)
- # devcards (2)
- # editors-rus (2)
- # emacs (2)
- # jobs (2)
- # ldnclj (2)
- # lein-figwheel (41)
- # off-topic (5)
- # om (50)
- # overtone (2)
- # re-frame (36)
- # reagent (1)
- # spacemacs (3)
- # yada (2)
@profil not sure what you mean, but you'd either had to use SSEs or send a separate request get new data anyway.
Is there a non-blocking get all messages on channel function in core.async
? Sort of like poll-all!
or similar?
Has anyone here worked on abstractions over regular expressions (or some other string matching mechanism)? Specifically looking to build some abstraction where non-technical users can build out filters that essentially “compile” to executable regexps
They are instances of java's regex but the literal to create one minimises the need for escaping, so you might need to do some editing after you created your regex with this
@sonelliot I'm assuming your chan is buffered since you have items in them. Perhaps running seq
on your buffer element would help: http://tgk.github.io/2013/10/inspect-core-async-channels.html
@jethroksy thanks for the info. I'll give that a go!
@profil: https://github.com/clojure/core.memoize maybe? it has a time-to-live mode.
what is the idiomatic way to perform updates to atoms if I have a map and I would like to change multiple key value pairs in one go
right now I am using #(swap! my-atom update-in [:key-i-want-to-modify] function-to-bring-about-modification )
but its seems like this only is pleasant for trivial updates
@adamkowalski: didn't have need to try it yet, but take a look at this - https://github.com/nathanmarz/specter
@jaen thank you, this looks amazing
I want to get the result of calling (f (f (f x))), where the number of nestings is arbitrary. Something like (defn nested-calls [fn initial n] (last (take n (iterate fn initial))))
. It seems to me like this is one of those things where there is most definitely a core function that does exactly this, which would be more idiomatic to call rather than to construct my made-up nested-calls fn, but I haven't come across it. Does anyone know if there is such an fn in Clojure core?
user=> (doc iterate)
-------------------------
clojure.core/iterate
([f x])
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effect
@reefersleep: maybe this ^
@reefersleep: recursion?
@reefersleep: I’m not sure if there’s a single function in core that combines all those together. Though I might use nth
in place of combining last
and take
.
@niwinz: Yeah, I thought that maybe there is something "related" to iterate
or this:
(defn produce
"Returns a lazy sequence of colls from a recursive, axiomatic,
transformative process."
[seed prep-f get-xf]
(letfn [(process
[coll]
(lazy-seq
(when (seq coll)
(let [new-coll (into (empty coll) (get-xf coll) (prep-f coll))]
(cons new-coll (process new-coll))))))]
(process seed)))
@hden: I am already using a loop/recur construct, but thought that it was a bit cumbersome. I've used loop/recur many times, and it has seemed cumbersome ever since the third time or so, because all I want to do it is to recur until a counter has reached zero. I'm thinking that
(loop [result coll
counter counter]
(if (zero? counter)
result
(let [new-result (... do stuff here)]
(recur new-result
(dec counter)))))
is really too much boilerplate to do that.@solicode: Cheers for the tip, that is neater.
@meow: I haven't gotten into into
yet
@meow: I'll have to have a look at your produce
when my brain's fueled up on sleep.
Could you give an example of your usage of produce
?
damnit, that's what I was doing (creating a Lindenmeyer implementation)
Thought I was being quick on the draw
https://github.com/decomplect/ion/blob/master/examples/ion/ergo/lindenmayer_systems.cljc
some use with quil here: https://github.com/pkobrien/sandbox/tree/master/quil_sketches/src/quil_sketches
Contains functions I do not know yet... Again, when I've had sleep.
Looks lovely minimal.
I was planning on exercising my implementation with quil too!
damnit
thought I was being (somewhat) original
Cool I'll have a look at it all.
Let me just push my latest changes, then you can see my impl - I think/hope it's simple enough to read through, even without documentation
it's a mix of WIP code and code I think works, though
What're you working with?
Looked like you had a knack though!
Not sure I understood that. You don't develop Braid yourself?
Think I read about it on the Clojure or ClojureScript subreddit
Sounds like a good idea
@moxaj: is that because the macro is expanded at compile time, but the binding happens at run time?
@stig nope, no macros involved here. Map returned a lazy sequence, and by the time it was evaluated, the binding was already gone
oh! I saw the \
` and ~@
and thought “macro” without noticing the defn rather than defmacro :-O
discussing this here reminds me of https://xkcd.com/541/