You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As requested by @jvoigtlaender this issue has been opened to propose changing the names (or at the very least aliasing the names to new names) of foldl1->reducel and foldr1->reducer or some variant there-of.
Immediate languages that come to mind that use this pattern are:
Clojure is a language where the artity of a function is part of the function, thus it uses reduce for both the reduce and fold variants, depending on whether an accumulator was passed or not.
The List.foldl was a hold-over from erlang where Enum.reduce was added by Elixir itself, hence the different type signatures, they can both work over enumerables though once properly massaged.
However, Elixir is one of those languages like Clojure where the arity of a function is part of its name, thus Enum.reduce/2 and Enum.reduce/3 are both supplied, however Enum.reduce/3 delegates to List.foldl/3 in the majority of cases.
On the above wikipedia list Haskell is the only language that uses foldl1 and foldr1, the general usage among the rest of the languages are various usages of reduce such as reducel/reducer, reduce_l/reduce_r, reduce_l/reduce_r, reduce/reduce_r, reduce/reduce_right and so forth with them using either another variant of reduce or using foldl/foldr to handle the Elm List.foldl and List.foldr style functions.
As seen reduce is used almost exclusively in languages that have a reduce/fold?1 style function, and both reduce and fold are used fairly evenly for fold style functionality depending on whether the language has default currying (like F# and Elm languages are) or whether the arity is part of the function definition (like Clojure or Elixir).
Thus to maintain consistency with the rest of near the entire functional ecosystem List.Extra.foldl1 and List.Extra.foldr1 should be at most renamed or at least aliased with List.Extra.reducel and List.Extra.reducer or some variant there-of as it is both more descriptive and functional language standard.
The text was updated successfully, but these errors were encountered:
Just for the record: I didn't request opening this issue because I endorse the proposal, I just requested it so that important information is all together in an opening comment, not in a long (previous) discussion thread.
As requested by @jvoigtlaender this issue has been opened to propose changing the names (or at the very least aliasing the names to new names) of
foldl1
->reducel
andfoldr1
->reducer
or some variant there-of.Immediate languages that come to mind that use this pattern are:
reduce
==List.Extra.foldl1
,fold
==List.foldl
):reduce
==List.Extra.foldl1
,reduce_from
==List.foldl
):reduce
==List.Extra.foldl1
,fold
==List.foldl
):reduce
for both thereduce
andfold
variants, depending on whether an accumulator was passed or not.reduce
==List.Extra.foldl1
,foldl
==List.foldl
):List.foldl
was a hold-over from erlang whereEnum.reduce
was added by Elixir itself, hence the different type signatures, they can both work over enumerables though once properly massaged.Enum.reduce/2
andEnum.reduce/3
are both supplied, howeverEnum.reduce/3
delegates toList.foldl/3
in the majority of cases.reduceLeft
==List.Extra.foldl1
,foldLeft
==List.foldl
):And I just found a document on wikipedia: https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Folds_in_various_languages
On the above wikipedia list Haskell is the only language that uses
foldl1
andfoldr1
, the general usage among the rest of the languages are various usages ofreduce
such asreducel
/reducer
,reduce_l
/reduce_r
,reduce_l
/reduce_r
,reduce
/reduce_r
,reduce
/reduce_right
and so forth with them using either another variant ofreduce
or usingfoldl
/foldr
to handle the ElmList.foldl
andList.foldr
style functions.As seen
reduce
is used almost exclusively in languages that have areduce
/fold?1
style function, and bothreduce
andfold
are used fairly evenly forfold
style functionality depending on whether the language has default currying (like F# and Elm languages are) or whether the arity is part of the function definition (like Clojure or Elixir).Thus to maintain consistency with the rest of near the entire functional ecosystem
List.Extra.foldl1
andList.Extra.foldr1
should be at most renamed or at least aliased withList.Extra.reducel
andList.Extra.reducer
or some variant there-of as it is both more descriptive and functional language standard.The text was updated successfully, but these errors were encountered: