[英]Is juxt the opposite of map? (In Clojure)
In Clojure we see the following examples of using map
: 在Clojure中,我们看到以下使用map
示例:
(map inc [1 2 3 4 5])
;;=> (2 3 4 5 6)
We observe that map
takes a function and applies it to each element in a collection. 我们观察到map
具有一个函数并将其应用于集合中的每个元素。
In Clojure we see the following example of using juxt
: 在Clojure中,我们看到以下使用juxt
示例:
((juxt inc dec) 2)
;=>[3 1]
We observe that juxt
takes a data structure and applies each function to it. 我们观察到juxt
采用数据结构并将每个函数应用于该结构。
My question is: Is juxt the opposite of map? 我的问题是: 与地图相反吗? (In that you map a data structure over a collection of functions instead of the other way around) (因为您将数据结构映射到函数集合上,而不是相反)
I don't think you can call juxt the opposite of map. 我认为您不能将juxt称为map的反义词。 Juxt composes a number of functions into one function that produces a sequence of the result of applying each of the functions to its argument(s). Juxt将多个函数组合为一个函数,该函数产生将每个函数应用于其自变量的结果序列。
我想juxt
可能是(应该是什么?)使用表达map
(DEFN juxt [&玩意儿(FN [&参数](图#(申请%参数))的玩意儿))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.