Fork me on GitHub
#clojure-uk
<
2021-12-03
>
paulspencerwilliams07:12:24

Morning. So who’s paying the bill for Pro Slack Access? πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅πŸ’΅

seancorfield07:12:15

@paulspencerwilliams Per #announcements Slack have given us a complimentary Pro subscription for a year and we can apply for an extension each year.

πŸŽ‰ 2
seancorfield07:12:03

@robert-stuttaford (one of the admin team) reached out to the head of Slack on Twitter and asked about it since we were in a free trial period of Pro, and this morning he and I were on an email thread with Slack's Chief of Staff for Customer Experience (what a great title) sorting out the details. We have reminders in place to reach out to Slack again in November '22 to ask for an extension.

seancorfield07:12:47

Has your sanity survived working with CSS?

paulspencerwilliams07:12:27

That’s great news - it’s nice to have history in Slack for our community. Haha, I’m just about clinging on. My woes yesterday were really more about build pipelines etc than the css per se.

seancorfield08:12:39

My sanity takes a hit every time I have to dive into CSS 😞 Same with JS. What little hair I have left just starts falling out every time I have to debug anything beyond the most basic JS.

paulspencerwilliams08:12:27

The language, the context, the ever changing landscape. I find front end stuff so tiring.

πŸ’― 1
mccraigmccraig08:12:44

i've just re-implemented the non-view part of re-frame for the backend - i'm sure you'd love it 😬

mccraigmccraig08:12:17

it's actually really nice - i did it for the evented logic in a data-oriented game, but after programming with it for a while i'm thinking of rolling it out for our APIs too

dharrigan08:12:41

Good Morning!

dharrigan08:12:50

Don't forget re:Clojure 2021 starting shortly!

dharrigan09:12:49

Here's the youtube link for the first day, starting at 09:45 UTC

mamapitufo09:12:36

heh, can't find any emails with the zoom links, and I can't join discord... everything is broken >.<

maleghast12:12:31

Morning all πŸ™‚

maleghast12:12:33

Does anyone know an idiomatic way to treat a list of vectors like a matrix, i.e. carry out operations on the columns represented by the positions in the vectors?

maleghast12:12:11

e.g.

([\a \b \a \a]
 [\b \a \a \a]
 [\a \b \a \b])

how could I count \a in the columns?

maleghast12:12:45

Or, am I better off creating new data-structures from each position in the listed vectors, i.e. transforming the above to this:

([\a \b \a]
 [\b \a \b]
 [\a \a \a]
 [\a \a \b])

Conor12:12:14

I don't know whether what you have is an actual matrix or you just want to treat it like one. If it's the former, maybe have a look at Neanderthal, that is the only thing that comes to mind for matrix operations in Clojure

Conor12:12:36

You might be able to use some of their code in any case

maleghast12:12:21

Thanks @conor.p.farrell I will take a look

Conor13:12:18

If it's just a list of things that you want to do a column sum on, it's no different than working with any sequence of data, I think - the Kotlin equivalent would be myData.chunked(rowSize).map { it[column] }.sum()

maleghast13:12:58

@conor.p.farrell - Basically I have a list of vectors (all the same length). I need to count the number of instances of a specific value in each of the columns represented by the positions in the vectors, and I have no idea how to do that.

maleghast13:12:03

So, in my first snippet above, I need to know how many \a there are in the notional column that is represented by (get % 0) if mapping over the list

maleghast13:12:37

but also for (get % 1), (get % 2), and (get % 3)

maleghast13:12:57

Which is why I asked if I am simply better off turning the list through 90-degrees (so to speak) and simply making a new list of vectors that has a row for each "column"

maleghast13:12:12

(not that I have the first clue how to do that in an idiomatic fashion either, fwiw)

maleghast13:12:24

In Python (or similar) I could just create a dataframe and then act on the columns

Conor13:12:22

Sorry, my brain is in Kotlin mode so I'm going to have to give code snippets that way.

val l = listOf(
            listOf(1, 1, 2, 2),
            listOf(2, 2, 1, 2),
            listOf(1, 2, 1, 2),
        )

        val rowSize = l.first().size
        val numColumnsMatching = (0 until rowSize).map { col -> l.map { it[col] }.count { it == 2 } }
Is that the kind of thing you're trying to do (replacing 'seeing if the value is 2' with your predicate?

maleghast13:12:02

Clojure feels like a language that should be able to do these things easily, but I have never had to do them before and I now realise that I haven't the first clue about how to do them.

mccraigmccraig13:12:30

(defn col [n m] (map #(get % n) m))
(defn count-col [n val m] (->> m (col n) (filter #(= val %)) count)
(->> (range 0 3) (map #(count-col % \a m)))

mccraigmccraig13:12:08

(ps: ^ probably won't work or even compile - i just typed it straight into slack 😬)

maleghast13:12:08

Thanks @mccraigmccraig - I will give it a try / tweak

maleghast14:12:53

@mccraigmccraig - This ^^ is EXACTLY what I needed, thank you !

maleghast14:12:57

(it works btw)

maleghast14:12:19

(you were just missing a paren at the end of the second line you pasted)

Rachel Westmacott15:12:24

also if you have a collection of rows you can (apply map vector rows) to transpose it into columns

πŸ‘ 1