Fork me on GitHub
#clojure-uk
<
2018-02-23
>
thomas07:02:26

I am off to berlin... for #clojured bye bye.

yogidevbear07:02:53

Is anyone else from this channel going to ClojureD?

dominicm09:02:20

I don't know how dust balls haven't made it into emoji form yet.

yogidevbear09:02:56

@dominicm I know, right?! or :tumble_weed:

yogidevbear09:02:05

Morning Jason 🙂

jarohen09:02:20

we've got one on our work slack, will copy it across

jarohen09:02:44

morning, btw 🙂

yogidevbear09:02:18

You rock! Thank you 😆

yogidevbear10:02:32

So on a clojure related front, I feel like I'm missing something fairly obvious here (please excuse the pointless nature of the example):

(def v [[:a1 :a2][:b1 :b2][:c1 :c2][:d1 :d2][:e1 :e2]])
(subvec v 2 4)
;=> [[:c1 :c2][:d1 :d2]]
(#(subvec % 2 4) v)
;=> [[:c1 :c2][:d1 :d2]]
(assoc-in [[:c1 :c2][:d1 :d2]] [1 1] "foo")
;=> [[:c1 :c2][:d1 "foo"]]
(map #(assoc-in (subvec % 2 4) [1 1] "foo") v)
;=> IndexOutOfBoundsException clojure.lang.RT.subvec (RT.java:1609)

yogidevbear10:02:52

I'm trying to apply assoc-in to a subvec of nested vectors inside a vector

reborg10:02:06

well, you're mapping in the last line, so the subvec is now at each element level

reborg10:02:44

np, I do those things all the time myself 🙂

yogidevbear10:02:14

Adjusted to the code below and it looks like I'm getting my expected result that I really want:

(map #(assoc % 1 "foo") (subvec v 2 4))
;=>([:c1 "foo"][:d1 "foo"])

yogidevbear10:02:05

Would there be a more idiomatic way of achieving this?

jarohen10:02:46

might be tempted to use for, but not really a lot in it

(for [[k _] (subvec v 2 4)]
  [k "foo"])
marginally more descriptive of what it expects the input/output formats to look like, maybe?

jarohen10:02:06

(assuming you're only doing the #(assoc % 1 ...) and not something significantly more complex)

yogidevbear10:02:34

Kinda, maybe for of #(assoc % :foo ...), but much of a muchness

yogidevbear10:02:55

This is also part of a concat operation

jarohen10:02:27

yeah, doesn't make enough of a difference if it's part of a wider computation 🙂

danm10:02:52

moin moin btw

mccraigmccraig11:02:08

anyone know of a lein plugin i can use to set some values in my project.cljs from a script ?

otfrom11:02:07

I wonder if the aero people have anything that will do that

otfrom11:02:25

dumb question of the day: can you add a fsepc to a defmethod?

otfrom11:02:49

(I remember reading somewhere you couldn't but I think I'm misremembering and google has been failing me)

mccraigmccraig12:02:48

doh, i'm dumb this morning too @otfrom - i completely forgot that project.clj is evaluated

minimal12:02:31

@otfrom no you need to use wrapper functions to add fspecs to multimethods and protocols

otfrom13:02:45

@minimal ok, so either delegate out to something fspeced or wrap w/something fspeced