Fork me on GitHub
#clojure-uk
<
2019-06-20
>
3Jane07:06:01

Guys, is there a good pattern for this kind of thing:

3Jane07:06:39

when you want to essentially reduce a collection (maybe drop some elements, maybe transform others)

3Jane07:06:04

and the decision of what to do with an element depends on what other elements have been previously processed

3Jane07:06:22

so, a good example would be converting a collection so that the result contains only unique elements

3Jane07:06:21

it can be done with reduce wherein carry value deconstructs into [state, actual_result], but that feels... meh

danielneal07:06:42

Alex Miller talks about making a distinct transducer here - http://insideclojure.org/2014/12/17/distinct-transducer/ - which puts the state in a volatile that is closed over

danielneal07:06:56

I often use the reduce with state though, as you describe, often in a map which I destructure in the reducing function

3Jane09:06:03

thanks for reminding me about map destructuring, it gives things a much cleaner feel 🙂

Ben Hammond07:06:10

fundamentally you have to have a state

Ben Hammond07:06:29

in a reducing function its an explicit accumulator

Ben Hammond07:06:50

in a tranducer its a closed-over volatile

Ben Hammond07:06:56

Personally I would prefer reduce and explicit accumulator (because I dislike subtlety in code)

👍 8
Ben Hammond07:06:12

but wrapping inside a transducer is more flexible

3Jane07:06:59

thanks 🙂

practicalli-johnny15:06:52

https://nextjournal.com/ is pretty amazing, just watched the Scicloj broadcast and I was very impressed. JUXT were also using NextJournal for their Crux workshop the other night

jasonbell16:06:31

@otfrom The teen suggested we watch Ghosts…. brilliant, very funny.

otfrom16:06:00

Ghosts is very good indeed

practicalli-johnny16:06:42

We have meetups organised for July and August live on the London Clojurians meetup site. https://www.meetup.com/London-Clojurians/events/262000841/ https://www.meetup.com/London-Clojurians/events/262441845/ Send me a DM if you want to speak in September, October or November. Or if you want to give a workshop before ClojureX. Thank you.

alexlynham17:06:54

how long are workshops @jr0cket and what’s been planned so far?

practicalli-johnny17:06:45

Nothing planned so far. Previous years we have done a 1.5 to 2 hour workshop in the morning and approximately 4 hour in the afternoon. But no reason why we can't have several smaller ones or an all day one (11am to 5pm).

practicalli-johnny17:06:32

I am sure a workshop on cljs and lambda would be popular (if only I knew someone who could give that)

alexlynham17:06:52

ha, or a guided conversation on hiring or something? those are workshop like and are really ace for knowledge sharing. You basically need 20 chairs in a circle, and no A/V

alexlynham17:06:04

facilitated a couple of those in the past too….

seancorfield17:06:24

I've never tried Spacemacs but I am quite fond of vim-style editing. Wish I could be there for the August meetup (I arrive the following week).

practicalli-johnny17:06:55

I should have a few videos that cover the same as the workshop on http://yet.vu/+practicalli Will also try and stream the workshop to the same channel. I am happy to meet up when you are over and go through some things if you like.

seancorfield17:06:04

Thanks. We're going to mostly be in West Sussex with mum or up in Stoke-on-Trent for a cat show/pet expo so I doubt we'll be in your area.

seancorfield17:06:42

If we happened to be in England around the date of one of your meetups, I'd probably make the effort to attend and meet folks 🙂

practicalli-johnny17:06:21

No problem. There are several hundreds of things I'd like to pick your brains about... If I find the time to ask :)

seancorfield17:06:47

Ooh, the July meetup looks awesome too. These get recorded and posted online @jr0cket?

seancorfield17:06:59

(now that Liquid is more vim-like, I've gone back to trying that more seriously, but I don't think I'll be able to give up parinfer/paredit)

practicalli-johnny17:06:44

I have asked SkillsMatter to record both talks (fingers crossed that their AV team is available).

4
djtango17:06:42

love the choice of talk about the socket repl

djtango17:06:24

ya - I was able to hack together a "replacement" to vim-fireplace in two lines of config thanks to socket-repl rich

dharrigan17:06:27

@djtango have a look at Conjure (https://github.com/Olical/conjure) as a work-in-progress replacement for fireplace that uses a socket-repl

djtango17:06:54

yeah Conjure sounds cool

djtango17:06:10

alas I don't use Neovim 😢

djtango17:06:37

I couldn't give you a rational answer why...

djtango17:06:53

other than I like minimalism

dharrigan17:06:50

fair enough 🙂