This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-20
Channels
- # adventofcode (29)
- # announcements (7)
- # aws (1)
- # babashka (3)
- # beginners (43)
- # biff (20)
- # clj-kondo (44)
- # cljs-dev (20)
- # clojure (74)
- # clojure-europe (24)
- # clojure-finland (2)
- # clojure-nl (13)
- # clojure-norway (3)
- # clojurescript (31)
- # code-reviews (1)
- # community-development (12)
- # cursive (3)
- # datomic (6)
- # emacs (1)
- # fulcro (25)
- # interop (7)
- # introduce-yourself (2)
- # leiningen (30)
- # nbb (3)
- # overtone (1)
- # podcasts-discuss (5)
- # polylith (24)
- # practicalli (1)
- # reclojure (1)
- # reitit (13)
- # rum (7)
- # shadow-cljs (12)
- # sql (23)
- # squint (51)
- # test-check (1)
- # testing (2)
- # tools-deps (2)
Hi all, I'm trying to figure out with bb and clojure-lsp. I'm just working on simple one-file script (without bb.edn), and now i'm trying to run LSP. LSP itself seems started normally, but, for example it can't find any definition. Maybe you can suggest me something to read about lsp and bb, because after googling for a while, I've got no understanding, should it work, if I use babashka deps inside my script but no deps.edn or not.
I see, it comes from lsp, not from kondo, kondo reports only unused requires (but flycheck don't), that's the err on line 28:
That sounds like a outdated clojure-lsp, could you share/check lsp-clojure-server-info
?
I updated clojure-lsp and the problem has gone. Actually I just had clojure lsp installed from incorrect tap. Thank you all.
yeah, I'd love to remove the outdated clojure-lsp from the core brew but they don't want it :)
Hey, I have this hash-set
selections (r/atom #{2 4 6})
How do I iterate over it and print each one alone?
(doseq [x @selections] (println x))
I have this array:
multi-select-items (r/atom ({:value A :id 27069} {:value B :id 27070}))
and this hash-set:
selections (r/atom #{2 4 6 27069})
How do I return all values from "multi-select-items" that are in "selections"?if you mean where the :id
is in the selections set, then this should work
(filter (comp @selections :id) @multi-select-items)
I mean the :id
in the mulit-select-items
atom. So for your example, I assume the result you want is a seq with only the first map in {:value A :id 27069}
so filter
takes a predicate and a sequence and returns a sequence containing only the elements where the predicate returns true. The predicate here is built by combining 2 functions with comp
. The first function that comp
will call is :id
which will get the :id
key from each map and pass it to the set in the selections
atom which will look that value up in the set. If it's not there, it will return nil
which is considered falsey by filter
and the resulting seq will not include that value. Does that make sense?
Yeah I understand, it returns nil now since selections has no :id
, if i has :id
, which I tried, it returns what I want. So, what can I do?
(let [multi-select-items (atom '({:value A :id 27069} {:value B :id 27070}))
selections (atom #{2 4 6 27069})]
(filter (comp @selections :id) @multi-select-items)) ;; => ({:value A, :id 27069})
this will return all the values in multi-select-items
where the :id
is in the selections
set. I'm not sure what you mean ...once you've filtered the list, you need to then map a transformation over that list. Maybe something like
(let [multi-select-items (atom '({:value A :id 27069} {:value B :id 27070}))
selections (atom #{2 4 6 27069})]
(->> (filter (comp @selections :id) @multi-select-items)
(map :value))) ;; (A)
in this instance there's a shorthand function keep
that you could also use, but this seems easiest to me.how to pass props in hiccups something like this?
<Canvas
direction="DOWN"
nodes={nodes}
edges={edges}
// node={(props) => <CustomNode {...props} />}
node= {function (props) {
return <CustomNode {...props} />;
}}
/>
const CustomNode = (props) => {
return (
<Node {...props} />)
Is there a way to do nested map destructuring? I can make do with this:
(let [{:keys [context]} {:context {:db "xxx"}}
{:keys [db]} context]
db)
Is there a way to express that shorter?sometimes :keys
can confuse you about how destructuring works. It is a bit of sugar. This might make it clearer how you can just use destructuring recursively
(let [{{thing :db} :context} {:context {:db "xxx"}}]
thing)
the :context
destructuring is itself destructuring, introducing the local thing
for whatever is at the key :db
inside of :context
Thanks @U11BV7MTK, the :keys
destructuring does make sense.
@U11BV7MTK On second thought it is confusing.
the keyword you destructure at is bound to a local of the same name. but in general the pattern is {local :key}
. And this can nest. {{thing :db} :context}
as above, or {{:keys [db]} :context}
Yes, understood. I'm trying to think how keys destructuring might (Does it?) work with multiple keys instead of a single one at top level. Named destructuring makes more sense there I guess.
{:context {:year "2022" :user "dr"} :data {:plant "apple :birth "2019"}}
Suppose I want to get year
and plant
and birth
inside a let
?
tcp=> (let [structure {:context {:year "2022" :user "dr"} :data {:plant "apple" :birth "2019"}}
{{:keys [year]} :context {birth-local :birth} :data} structure]
[birth-local year])
["2019" "2022"]
(let [{{year :year} :context {:keys [plant birth]} :data} m] ...)
makes sense. I'm not sure if it's possible to keys destructure at top level.tcp=> (let [{foo :foo} {:foo "top level is just where you are"}]
foo)
"top level is just where you are"