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

Post on 15-Jan-2017

154 Views

Category:

Engineering

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Transducers for ruby developers

@ilavriv

About MeFront - 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)

ImplementationClojure - 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

Linkshttp://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?

top related