Earlier quoted context omitted.
Nah, Clojure seqs are more like .NET/LINQ enumerables. Functions that work over seqs/enumerables return a new seq/enumerable. From what I understand, and I'm sure I am wrong, a transducer receives and transforms a value, and may call the next transducer with the transformed value. The nice thing is that a transducer does not create intermediate results (a seq/enumerable), and that it doesn't make any assumptions on t…
A contrived example in C#/LINQ Enumerable.Range(1, 100) .Where(n => n % 2 == 0) .Select(n => n * 2) .ToList(); And as a transducer it could looks something like this? sequence( Enumerable.Range(1, 100), compose( filter(n => n %2 == 0), map(x => x + 1) ) ).ToList(); On the linq side it would create only 2 enumerable objects (one for where and select) and the ToList would result in a copy the object pointer as it was p…
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.