Git Product home page Git Product logo

transducers-ruby's People

Contributors

dchelimsky avatar puredanger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

transducers-ruby's Issues

Example of passing in attributes

I've implemented a few custom transducing functions using this library (and your excellent JavaScript port).

After following the documentation here: http://www.rubydoc.info/gems/transducers/Transducers

Is their an idiomatic way of passing in additional parameters to transducing functions? E.g. perhaps if you're operating on an array of hashes, you could supply the hash key that the transducing function would use.

That said, I may be missing some fundamental concepts of how transducers are designed to work (and I have not used them in Clojure yet).

More idiomatic Ruby

Not to be a Debby Downer, but this doesn't feel at all like idiomatic Ruby.

I think the biggest improvement would be to mix in a transduce method into Enumerable, with a signature closer to Enumerable#reduce. The other thing that feels wrong is that almost everything is a class method. It seems like a more idiomatic way to do it would be with a block using instance_eval, so we could do something like:

(1..100).transduce([], :<<) do
  filter(:even?)
  map{ |n| n * 2 }
  take(5)
end

For composabilitiy:

first_5_even_doubled = Transducer.compose do
  filter(:even?)
  map{ |n| n * 2 }
  take(5)
end

(1..100).transduce([], :<<) do
  first_5_even_doubled
end

I'll have to think about this some more, and see if I can contribute some code back to implement a more idiomatic way of doing this in Ruby, while keeping composability in mind.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.