为什么在 javascript 中采用名称 `reduce` 而不是 `fold`?
why the name `reduce` was adopted instead of `fold` in javascript?
我搜索了这个主题,但我不知道要搜索什么关键字所以我 post 这个问题。
我想知道为什么在javascript中选择了这个名字reduce
,即使这个名字已经被使用过,比如fold
或accumulate
,这是更传统和有意义(这是我个人的看法)。
我和我身边的人谈过这个话题(我认识的人之一,他长期与 Javascript 打交道,并且还使用函数式语言,如 Scheme、Racket和 Clojure)。他谨慎地推测,这可能是Python.
的影响。
如果您有任何我不知道的传统语境,或者您知道这个名字的背景,如果您能回答我将不胜感激。
如果你看一下 https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Folds_in_various_languages, you can see that the most common names for this operation are fold
, reduce
, and inject
. reduce
is by no means an unusual name. In particular, reduce
is used in Perl (which JavaScript copied many features from), and Perl probably got it from Lisp (like many other features). The earliest reference I can find is REDUCE
in Common Lisp(在 1980 年代开发并在 1994 年标准化)。
我搜索了这个主题,但我不知道要搜索什么关键字所以我 post 这个问题。
我想知道为什么在javascript中选择了这个名字reduce
,即使这个名字已经被使用过,比如fold
或accumulate
,这是更传统和有意义(这是我个人的看法)。
我和我身边的人谈过这个话题(我认识的人之一,他长期与 Javascript 打交道,并且还使用函数式语言,如 Scheme、Racket和 Clojure)。他谨慎地推测,这可能是Python.
的影响。如果您有任何我不知道的传统语境,或者您知道这个名字的背景,如果您能回答我将不胜感激。
如果你看一下 https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Folds_in_various_languages, you can see that the most common names for this operation are fold
, reduce
, and inject
. reduce
is by no means an unusual name. In particular, reduce
is used in Perl (which JavaScript copied many features from), and Perl probably got it from Lisp (like many other features). The earliest reference I can find is REDUCE
in Common Lisp(在 1980 年代开发并在 1994 年标准化)。