Fork me on GitHub
#beginners
<
2015-08-05
>
escherize16:08:39

I know there's a better way to conditionally include a map entry in a map.. say:

{:a 1 (when (pred?) :b) (when (pred?) 2)}

escherize16:08:22

I think this is better:

(cond-> {:a 1} (pred?) (merge {:b 2}))

escherize16:08:39

but is there a.. clearer(?) way than that

alexmiller16:08:46

I think some people have an assoc-if or something like that

escherize16:08:16

like: (assoc-if (pred?) {:a 1} :b 2) ?

escherize16:08:58

oh, found a s.o. about it

escherize16:08:15

interesting approach:

(conj m (when value [key value]))

alexmiller16:08:32

hey that points to a blog I wrote that I don't remember writing :)

escherize16:08:27

Haha, nice job

escherize16:08:37

?assoc is similar

luisnramirez18:08:16

Hi, so if I develop a web app in clojure, where do you usually host it (for free?) I've been hosting my java webapps in openshift which provides containers like jetty or tomcat

surreal.analysis18:08:09

Heroku has solid Clojure support

einherjar18:08:56

In ClojureScript what is the most idiomatic way to access a nested values?

(aget js/e.target.files 0)
(aget (.-files (.-target e)) 0)
(aget (.. js/e -target -files) 0)

surreal.analysis19:08:36

I think it’s just

(aget js/e target files 0)
@einherjar

einherjar19:08:45

Thanks @surreal.analysis I couldn’t get that to work though. I looked though some code on GitHub and I’ve seen all three used. I guess it doesn’t matter as long as I’m consistent, they look like they all compile down into the same thing.