作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有什么区别:
(transduce (comp fn-1 fn-2 fn-3) conj vector-collection)
(eduction fn-1 fn-2 fn-3 vector-collection)
最佳答案
transduce
通过将归约函数应用于集合来归约转换器。计算结果。eduction
只是记住您想将传感器应用于集合的东西。 Eduction 本身并不是“常规意义上的”集合,而是实现了它的接口(interface)。因此,当您尝试打印它时,它会像顺序一样打印自己。
看这里:
(defn my-tran [rf]
(fn
([]
(println "Arity 0!")
(rf))
([res]
(println "Arity 1!")
(rf res))
([result input]
(println "Arity 2!")
(rf result input))))
> (def a (transduce my-tran conj '(1 2 3)))
Arity 2!
Arity 2!
Arity 2!
Arity 1!
#'test.core/a ;a is already finished
> (def r (eduction my-tran '(1 2 3)))
#'test.core/r ;nothing was done
> r
Arity 2!
Arity 2!
Arity 2!
Arity 1!
(1 2 3) ;now it's done. Next call with calculate it again. Check it.
> (sequential? r)
true
eduction
是将转换器部分应用于没有归约函数的集合。但它不是
lazy-seq
.所以当你
transduce
或
reduce
超过
eduction
它与调用
transduce
是相同的(在此时完成相同的工作的意义上,而不是在结果的意义上)。对原始集合具有缩减功能。
关于clojure - 教育与换能器组成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32822207/
我实现了自己的简单版本的双向链表。不幸的是,它似乎有一个错误。列表的头部似乎移动到新的Node , 每次加一个 push_back .正因为如此,print将无限期地打印最后一个值。 链表: stru
调用 (eduction ..) 在 REPL 中返回一些看起来像序列的东西(即像“(1 2 3)”这样的东西)。但是,如果您检查此返回值是否是一个序列(通过 seq?),则会得到 false。 问题
这个问题不是实际问题,我只是在寻找对观察到的事件的合理解释。我正在阅读 Seamless R and C++ Integration with Rcpp (Use R!) 德克·埃德尔比特尔 (Dir
我和我的小组正在尝试用 DE2-115 板为我们的本科顶点项目创建一个合成器。 我们唯一想不通的是如何将频率映射到通过板上音频端口正确输出的“键”。我们搜索了网络,所有提供的文档都包含编解码器的数据表
我是一名优秀的程序员,十分优秀!