This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-09
Channels
- # aws (3)
- # beginners (61)
- # boot (1)
- # cider (80)
- # clara (5)
- # cljs-dev (5)
- # cljsrn (19)
- # clojure (40)
- # clojure-dev (29)
- # clojure-dusseldorf (2)
- # clojure-greece (21)
- # clojure-italy (16)
- # clojure-russia (7)
- # clojure-spec (31)
- # clojure-uk (70)
- # clojurescript (31)
- # cursive (21)
- # data-science (5)
- # emacs (7)
- # fulcro (23)
- # graphql (4)
- # java (18)
- # jobs (1)
- # jobs-discuss (25)
- # juxt (14)
- # nrepl (2)
- # off-topic (18)
- # om-next (2)
- # onyx (3)
- # re-frame (16)
- # reagent (50)
- # ring-swagger (5)
- # shadow-cljs (70)
- # specter (5)
- # sql (24)
- # tools-deps (16)
- # vim (41)
For lisps I've started Land Of Lisp, which is a fun intro, also I've been doing a lot of elisp with emacs so that I find is a great value add, despite the difference in data structures.
If I have a reducible thing and a transducer, what’s the best way to use some
with it?
I have (iterate/tree-seq)
which returns an IReduceInit
impl which iterates over the tree. I’d then like to filter and map the elements, and stop when I meet one matching some criteria.
Something like (some whitespace? (comp (filter string?) (map something)) (iterate/tree-seq element))
Perhaps (some whitespace? (eduction (comp (filter string?) (map something)) (iterate/tree-seq element)))
?
The best option I’ve been able to come up with is:
(transduce (filter psi/whitespace?)
(completing (fn [ret item] (if (psi/whitespace? item) (reduced true) ret)))
false
(iterate/tree element))
But that is pretty ugly. Is there a prettier way?Or just using reduce directly, but still not easy to understand:
(let [f ((filter psi/whitespace?) (fn [ret item] (if (psi/whitespace? item) (reduced true) ret)))]
(reduce f false (iterate/tree element)))
(transduce (comp (filter psi/whitespace?) (halt-when psi/whitespace?))
identity
false
(iterate/tree element))
It still feels odd. I think the direct reduce
version makes the most sense, except for creating the reducing function by invoking the transducer.
I think part of my confusion is that reducing is inherently tied to having an accumulated value, which I never use in this case.
maybe make a true in-order (or whatever traversal) of the tree? and then just do a some first?
Yeah, I actually have a tree-seq which returns a seq over the tree, but I was trying to do it imperatively rather than use the lazy seq.
Hi, sorry for beginners question. What is the use case for dynamic functions? (defn ^:dynamic …
@fixxer The var is the thing thats dynamic, and this allows you to "rebind" certain vars on a "per thread" basis. Example- lets say that you have somebody else's function that uses println all the time, and you want only the console output from one thread (like, inside a long-running go block) to go to a separate log file. Println uses a dynamic var for its console printing, so if you rebind that then suddenly all those println calls go where you want them.
If go blocks work how I think they do, that is
@fixxer There are no beginner questions. Just go ahead and ask what you want to know, to live means to learn 🙂 Also there is a #beginners channel if you feel more comfortable there.
Yeah, nobody is born knowing Clojure
I'm looking for an efficient way to transform a nested map:
{:n0 {:k1 "key 0 - 1"
:k2 "key 0 - 2"
:n1 {:n1.1 {:k1 "key 1.1 - 1"
:k2 "key 1.1 - 2"}
:n1.2 {:k1 "key 1.2 - 1"
:k2 "key 1.2 - 2"}}
:n2 {:n2.1 {:k1 "key 2.1 - 1"
:k2 "key 2.1 -2"}}}
to
{:k1 {:n0 "key 0 - 1"
:n1 {:n1.1 "key 1.1 -1"
:n1.2 "key 1.2 - 1"
:n2 {:n2.1 "key2.1 -1"
:k2 {:n0 ...}}
not sure how to 'inverse' the nesting (keys of leaf nodes become the root nodes - there are only a limited number of leaf keys)
@kurt-o-sys have you tried looking at a lens library ?
i like https://github.com/ctford/traversy myself
I'll look at it... experimenting with specter now, I'm pretty close. I'll give a look at traversy.
🙂 got it working...
https://gist.github.com/samedhi/1405ff302ef9819f8f4f9d43099d3d38 <= Having some trouble figuring out why I can’t reify this java Interface, any help is appreciated.
Ah, it is this EventListener http://googlecloudplatform.github.io/google-cloud-java/0.37.0/apidocs/com/google/cloud/firestore/EventListener.html
Fudgsicles, forgot to include the this
in the implementing method again. I do this like once a week!