Transducers for ruby
developers
@ilavriv
About Me
Front - End Engineer temy.co
Rust meetups co - organizer
speeker
Teacher for PLLUG Community
twitter: @ilavriv
github: lavriv92
History
Presented by Rich Hickey
Implemented on Clojure
What is transducers
Composable algorithmic transformations
Concept of transducers
All operations with collections can be implemented with redice function
We don`t know nothing about types of collections
We can compose results
Collectiong results of computions
Function composition
compose(collection, transformation1, transformation2, … , transformationN)
But!
Results not reusable
Different types of results
Signature
(whatever, input -> whatever ) -> (whatever -> input -> whatever)
Implementation
Clojure - native
Erlang
Ruby
Python3
Why i can use transducers
Text processing
Operations for collections map, filter, reduce
Needs better performance
Transducers
map
filter
take
...
Transducers and Ruby
require ‘transducers’
T = Transducers
t = T.compose(
T.filter(:even?),
T.map(|n| n * 2),
T.take(5))
result = T.transduce(t, :<<, [], 1..100)
Ruby
transducers-ruby by cognitech lab
Github: https://github.com/cognitect-labs/transducers-ruby
Links
http://clojure.org/transducers
http://clojure.com/blog/2012/05/15/anatomy-of-reducer.html
https://www.youtube.com/watch?v=6mTbuzafcII
http://cognitect-labs.github.io/
Questions?

Іван Лаврів "Transducers for ruby developers"