clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
2020-09-30T08:13:24.094Z

driech here today

slipset 2020-09-30T08:18:28.094200Z

GOd morgen

plexus 2020-09-30T08:24:25.094400Z

morning!

slipset 2020-09-30T08:44:35.095600Z

So in some talk or another Rich says that sets are undervalued and underutilized data structures, and I see from our code that in many places where we could have used sets, we end up using lists or vectors.

1
slipset 2020-09-30T08:45:07.096300Z

Much because map/filter et al don't preserve the type of the input collections.

slipset 2020-09-30T08:45:55.097200Z

But I have a feeling that that adding maps and filters would probably be the wrong approach and that this should rather be handled with transducers in some way? Thoughts?

slipset 2020-09-30T08:46:09.097600Z

Btw this one is rather nice:

user=> (disj #{"foo" "bar" "baz" nil} nil)
#{"foo" "bar" "baz"}
user=>

slipset 2020-09-30T08:47:29.098300Z

compared to

user=> (filter identity ["foo" "bar" "baz" nil])
("foo" "bar" "baz")
or
user=> (remove nil? ["foo" "bar" "baz" nil])
("foo" "bar" "baz")
user=>

thomas 2020-09-30T08:49:38.098500Z

morning

raymcdermott 2020-09-30T08:59:18.098800Z

morning

2020-09-30T09:02:51.100Z

@slipset interesting. I've noticed lately that I'm only really using filter/map/etc in the context of transducers so I'm usually preserving the type of the collection by doing into or transduce with a collection type (same w/reduce)

2020-09-30T09:02:57.100200Z

so I've not had that problem

2020-09-30T09:03:11.100600Z

I love sets and use them for deduplication and as predicates quite a lot

2020-09-30T09:03:57.101300Z

(into #{} (filter identity) [:foo :bar :baz nil])

2020-09-30T09:05:20.102100Z

I frequently have things like

(if (#{:foo :bar} (:my-key my-map)) do-this do-that)

slipset 2020-09-30T09:05:51.102600Z

Yeah, I love the fact that sets and maps acts as fns.

slipset 2020-09-30T09:06:48.103200Z

One could choose to get annoyed by the fact that keys doesn't return a set

2020-09-30T09:07:38.104Z

yeah, keys should return a set (as they are unique by contract)

slipset 2020-09-30T09:08:35.104500Z

(fnil conj []) seen and used before 🙂

slipset 2020-09-30T09:10:42.104800Z

This use of transducers is a bit interesting:

slipset 2020-09-30T09:12:01.106100Z

Any reason for that instead of

(->> (get tagged-episode ::edit) (map ::command) (into #{}))

slipset 2020-09-30T09:12:39.106600Z

Since you're not composing the transducer?

jasonbell 2020-09-30T09:29:19.106800Z

Morning

2020-09-30T09:32:57.107600Z

@slipset not a good one other than consistency and every time I end up having a single thing in my trasnducer pipeline the universe laughs and says "ha! you need another"

😂 1
2020-09-30T09:34:39.108600Z

when I write them I tend to do the following:

(into #{}

  my-coll)
and then put the transducing functions in the middle as I work through it

2020-09-30T10:50:01.109300Z

I used to write my ->> like this

(->> my-coll

  )

2020-09-30T10:52:32.109800Z

so moving from thread last to into wasn't a big shift for me really

2020-09-30T10:53:00.110400Z

most of the things about transducers go on about the internals and are a bit light on the using, which wasn't too hard once I grokked how to go from one to another

2020-09-30T13:36:49.111Z

@slipset literally comping in another xf into an into as I need to filter some things out before I do a sort. 😉

ordnungswidrig 2020-09-30T13:40:50.111200Z

Good afternoon

2020-09-30T14:38:12.111500Z

good day to you sir!

ordnungswidrig 2020-09-30T14:55:21.111700Z

What an honor!

borkdude 2020-09-30T15:51:38.112300Z

What are the most useful Java classes to use reify with in your opinion?

2020-09-30T16:49:58.112900Z

clojure.lang.IReduceInit? is that cheating?

2020-09-30T16:51:01.113500Z

java.util.Iterator and java.util.Iterable are also big favourites

dominicm 2020-09-30T18:08:09.113700Z

All of them

dominicm 2020-09-30T18:08:31.114400Z

I doubt you could get a non biased answer. Maybe try a github search or something.

borkdude 2020-09-30T20:19:55.114800Z

@dominicm I already analyzed a bunch of code: https://github.com/borkdude/analyze-reify

dominicm 2020-09-30T20:31:54.115300Z

Ah, so deref then :)