5

Calling (eduction ..) returns in a REPL something that looks like a sequence (i.e., things like "(1 2 3)"). But if you check whether this return value is a sequence (via seq?), you get false.

Question: What exactly is an Eduction? Is it merely a list of values that will be fed, one by one, into a reduction function?

George
  • 6,927
  • 4
  • 34
  • 67

1 Answers1

7

According to transducer's doc:

To capture the process of applying a transducer to a coll, use the eduction function. It takes any number of xforms and a final coll and returns a reducible/iterable application of the transducer to the items in coll. These applications will be performed each time reduce/iterator is called.

So it is an abstraction for applying transducers to a collection which produces something reducible/iterable. You might wonder what's the difference:

Seqs differ from iterators in that they are persistent and immutable, not stateful cursors into a collection

As they will go over the supplied collection apply transducers each time they are reduced/iterated over, they differ from seq's semantics.

Piotrek Bzdyl
  • 12,965
  • 1
  • 31
  • 49