Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

foldl1/foldr1 should use descriptive names as the '1' imparts no information #15

Open
OvermindDL1 opened this issue Aug 19, 2016 · 3 comments

Comments

@OvermindDL1
Copy link

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:

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 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.

@jvoigtlaender
Copy link
Contributor

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.

@Mouvedia
Copy link

It should probably be camelcased though.

reduceL / reduceR

@OvermindDL1 https://rosettacode.org/wiki/Catamorphism

@prikhi
Copy link
Member

prikhi commented Jan 9, 2017

I like reduceL or reduceLeft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants