DEV Community

Discussion on: Advent of Ruby 3.0 - Day 03 - Toboggan Trajectory

Collapse
 
joshcheek profile image
Josh Cheek
  • The tree hits would be simpler to calculate with Enumerable#count than Enumerable#reduce.
  • I did not know about Range#%, and Ruby 3's Array#slice taking an enum is super cool!
  • I feel like your explanation of monoid / group / abelian group makes more sense than anything I've read trying to understand this stuff. Maybe I'm primed, but I also feel like the explanation was simple and concrete, which made it not seem all "wtf?" like it usually does.
  • I really like that you included the Ractor experimentation, even though you haven't got it figured out yet ^_^ I'll be interested to see how they work if you do!
Collapse
 
baweaver profile image
Brandon Weaver

On 1: Enumerable#count vs Enumerable#reduce you're correct, but I did it intentionally to set up the Monoid intro as something that is "reducible" is by its nature parallelizeable if you can express it like I did before mentioning that.

On 2: Array#slice and Range#% are a lot of fun, though I still prefer Range#step for clarity. Truthfully I wasn't sure that'd work either with slice and was pleasantly surprised.

On 3: Granted my entire "Reducing Enumerable" talk was a very thinly veiled Monoid tutorial, and that always gets some fun reactions when I tell people that's what they just learned. People like using mathematical terms to teach people who don't know math terms, and predictably it doesn't fit their internal metaphor catalogue. Conversely this would probably annoy a mathematician.

On 4: I feel like I'm right there. I could make this work with threads and TruffleRuby but I want to get it to work T_T