News for hackers. Stuff that matters.
Re:Rich Hickey – Inside Transducers [video] by ajanuary on Friday November 21, 2014 @04:24PM (#8643449)
With Linq you can't really create an object/function that describes the transformation that should happen. I start with an enumerable, describe how to transform /that/ enumerable, and in the end have something that describes a transformation applied to a particular initial data. I can't do anything with it but laziy read the transformed values for the original input.

With transducers I can describe a transformation that should happen to /some/ reducable input, and in the end have something that represents just the transformation. I. An then apply that to any reducable input I have.

[edit]

Your example becomes:

  var incrementedEvens = compose(
      filter(n => n %2 == 0),
      map(x => x + 1)
  );
  transduce(Enumerable.range(0, 100), incrementEvens);

  var lowerAlph = compose(
    filter(x => Character.isAlpha(x)),
    map(x => x.ToLowercase())
  );
  System.in.setTransducer(lowerAlpha);
You can really do that in Linq.

There are no comments on this comment yet.