2016-02-23 39 views
4

调用在REPL东西,看起来像一个序列(即,像“(1 2 3)”)(eduction ..)回报。但是,如果你检查这个返回值是否为一个序列(通过seq?),你会得到false什么是clojure Eduction?

问题:究竟什么是教育探? 难道仅仅是值的列表将被送入一个接一个,成一个缩小功能?

+1

可能是一个重复:http://stackoverflow.com/questions/31986435/clojure-transducers-behavior/31992370#31992370 – ClojureMostly

回答

4

根据transducer's doc

要捕获应用转换到科尔的过程中,使用的排出功能。它接受任何数目的XForms和最终科尔并返回传感器在科尔的项目可还原/迭代应用。每次调用reduce/iterator时都会执行这些应用程序。

所以它是一个抽象的应用传感器的集合产生的东西reducible/iterable。你可能不知道有什么区别:

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

当他们将仔细收集提供的传感器应用每次被缩短时间/遍历,他们从SEQ的语义不同。

相关问题