Fork me on GitHub
#clojure-uk
<
2017-04-06
>
thomas07:04:07

mogge 😼

Rachel Westmacott08:04:06

random core function of the day

clojure.core/bases
([c])
  Returns the immediate superclass and direct interfaces of c, if any

dominicm09:04:06

How often to you use bases?

Rachel Westmacott09:04:05

are you suggesting that people choosing functions that they think are useful might be better than random selection?

Sam H11:04:03

I think it's fine to pick a random function and then see who uses it. Could indicator of 1) who is aware of it and also 2) how useful it is. Probably needs a How many people new about this function? comment too

dominicm17:04:32

My question was really: what would you use that for?

Sam H11:04:21

How many people knew about bases?

thomas11:04:15

nope , nor have I ever felt the need for it

korny15:04:03

ok, dumb question time - is there a core function that maps a function and a unique sequence (or a set) into a map where the keys are the original sequence, the values are f(key) ? like group-by but the other way around?

korny15:04:35

so thing(inc, #{1 2 3}) would produce {1 2, 2 3, 3 4}

korny15:04:01

I can do it with (zipmap vals (map inc vals)) but it feels like there should be a single function, my cheat-sheet-fu is failing me.

tcoupland15:04:19

I don't think there's one, zipmap is it :)

korny15:04:10

I’ve also been known to abuse (into {} (for [x things] [x (f x)]))

korny15:04:24

or in this case (into {} (map #(vector % (f %)) things) - but somehow I find the for syntax easier

minimal15:04:07

or (into {} (map (juxt identity inc) #{1 2 3}))

minimal15:04:25

for juxt fun

korny15:04:31

why is there no juxt emoji?

korny16:04:38

bwahahaha 🙂

malcolmsparks16:04:45

@korny there is also partition with overlap

malcolmsparks16:04:48

(partition 2 1 (range 10))

maleghast19:04:27

@malcolmsparks That's really nifty 🙂