This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (1)
- # beginners (115)
- # calva (7)
- # cider (8)
- # clj-kondo (3)
- # cljdoc (12)
- # clojure (54)
- # clojure-europe (4)
- # clojure-italy (5)
- # clojure-nl (6)
- # clojure-spec (70)
- # clojure-uk (88)
- # clojurescript (54)
- # core-async (16)
- # cursive (5)
- # datomic (31)
- # editors (4)
- # emacs (4)
- # fulcro (29)
- # graphql (17)
- # luminus (1)
- # lumo (2)
- # off-topic (37)
- # pathom (16)
- # random (2)
- # re-frame (5)
- # reitit (3)
- # rum (2)
- # shadow-cljs (192)
- # sql (17)
Is there a succinct way of reducing an array of maps into a single map where all the values of the maps are summed?
So, after a bunch of searching I still can’t figure out where standard out ends up. I’m doing a small web app thing with Lein, Ring, Compojure, Hiccup. Not sure how to track it - does Lein or Ring configure it? I’m trying to do the old print statements in my handlers.
You can redirect stdout I believe by binding https://clojuredocs.org/clojure.core/*out*
@mattias504 and just (prn “hi”) doesn’t end up in the lein repl out? How are you starting your repl?
Well...it turns out, I should have kept quiet a while longer. Thanks for replying, but this was, of course, just another case of... programmer error. Turns out, even with few lines of code confusion can arise. What can I say, years of compilers complaining of types has made me weak 😩
Hey, I am a beginner in clojure. Have worked on one simple project. Can someone let me know what possible questions can a beginner be asked during a clojure interview?
you need to receive it on a channel and bind it, either by swapping it to an atom or receiving in a let binding.
though I might consider just using an output channel you can pass around to that go block function, and use the return channels more for synchronization.
though that is still a blocking receive, so all you've done is blocked that let statement until the go form sends the return value through the channel.
that's correct, you can't block in clojurescript. 🙂 you'll need to pass in a channel and maybe use promises, so check out
another option here is
take! which is async, and has an optional callback arg to be invoked when the value comes in
what’s the idiomatic way of taking a bunch of expressions that might be nil, and getting a list of only non-nils?
(defn foo [thing & others] (prn thing) (when (seq others) (prn others))) (foo 1 (when false 2))
calling next on rest-children sounds like a bug. Since
(next [:a]) returns nil, your rest-children could have valid values and not render in that way.
It sounds like you're got some confusing logic somewhere. I imagine there's a way out of this
=> nil (defn foo [thing & others] (prn thing) (when (seq others) (prn others))) => #'fy.repl/foo (foo 1 nil) 1 (nil) => nil
i'm not able to access /S1&L1&particle like I expect with that last line, moving it to the top doesn't catch the pattern any longer either it seems... any help?
(GET "/S:section&L:lesson&P:part" [section lesson part]) (GET "/S:section&L:lesson" [section lesson]) (GET "/S:section&L:lesson&:drill" [section lesson pre-strdrill])
a compojure "route" is actually just a handler function that returns nil if it doesn't match
On ClojureScript specifically: can anybody briefly explain what is the semantics of
#object[Constructor ...] compared to
#js ... ?
Like, can an
#object[...] (btw, is it called a native object?) be used like a map or vector? How does one work with it in cljs?
(btw, I'm glad to have joined this community... I can't wait to start contributing code and answers. Thanks in advance!)
If the printing system (which is a little different in cljs from clojure, so I don't know the specifics) doesn't have a rule like "print seqs as ( then coma separated values then )" that matches when asked to print some random thing, it prints them like that
it used to be the case that those would print as
#<...> which was sometimes referred to as unreadable objects, but there were changed to print that way which matches up more with the tagged literal syntax, which you can fiddle with to read those objects (but good luck reading that getting the "original" object back), so you can't really call them unreadable objects any more
they convert into one another... but there's nothing like
#object  doesn't tell you anything about the object except that there is no custom printer defined for it
#object I've always thought was a js object. So you had to use the js interops like
so you cannot use it to answer any question about the object except "does this have a custom printer defined for it"
Ok... So, if I understand correctly, a JS object is printed as
#js ... if its prototype is Object, while objects from other constructor are printed as
#object [Constructor ...]
if I have a JS object
obj, I can access its property
obj.name... CLJS-side, it looks like
#object [Person ... ] but how do I get its
(.name obj) doesn't seem to work (it looks for a function named
can I use clojure to implement a java interface, then generate a jar, then have a foreign java library use that jar, as a kind of plugin?
reason i'm asking is because the docs say the resulting class might be "anonymous"
if it's anonymous, and a foreign java library is expecting a class that implements a given interface, will that work out?
yes, you could do this with deftype (would probably want to use the
:load-ns option in deftype too)