Fork me on GitHub
#clojurescript
<
2018-02-09
>
rnagpal14:02:01

I wanted to split my project into a muti-project I am able to split the CLJS files into a separate project, then build it(create jar) and add it as a dependency in my main project Now I am struggling with two things 1) Can I split the generic less files also into a generic project ? We have a generic CSS framework which are not tied to the components, so the project will just contain less files. 2) In my multi project, when I update the sub project CLJS files, I dont want to go through the entire deploy and import process. I tried the checkouts folder which is mentioned in the lein docs, but its not working for me https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies

eveko15:02:37

How can I get a map from a vector of maps based on value of a key? {:data [{:id 1 :b 2 :c "some string"} {:id 2 :b 4 :c "some other string string"} ...]} How can I extract for example {:id 1 :b 2 :c "some string"} By the value of the key :id

eveko15:02:39

I feel like an idiot for asking but I could not find anything remotely usefull on google... 🤐

jmromrell16:02:39

@eveko You can use (some #(= 1 (:id %)) vec-of-maps)

jmromrell16:02:31

some returns a truthy value as long as there is at least one value in the collection for which the predicate is true. It just so happens to return the first matching element as that truthy value

jmromrell16:02:21

Alternatively, you could do something like: (first (filter #(= 1 (:id %)) vec-of-maps))

jmromrell16:02:09

Since filter is lazy, it will only process up until the first value found. I prefer some, however. It's a bit more concise, and I think I've run into issues with filter or other similar transducers processing batches of data (so you may process more elements than you actually consume sometimes)

eveko16:02:34

the first one is returning true for some reason though

jmromrell16:02:16

Oh, oops, let me rewrite. I forgot it returns the result of the predicate, which in this case is a boolean since I am using equals

jmromrell16:02:28

(some (fn [x] (when (= 1 (:id x)) x)) vec-of-maps)

jmromrell16:02:11

At that point it's less concise though. Pick your poison 🙂

eveko16:02:22

Could rename it into a function

eveko16:02:07

thanks allot it works great. This really should have been easier to find online 😮

josesanch16:02:38

Hi. Is there a recommended way to do multilingual routing in cljs?