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

Sequence cleanup: fold vs reduce, more powerful scan #3316

Open
fridis opened this issue Jul 5, 2024 · 1 comment
Open

Sequence cleanup: fold vs reduce, more powerful scan #3316

fridis opened this issue Jul 5, 2024 · 1 comment
Labels
base library related to the Fuzion base library cleanup improve code quality

Comments

@fridis
Copy link
Member

fridis commented Jul 5, 2024

foldf is redundant with reduce, and fold* generally provides the same functionality like reduce*, so we should think of better names, e.g.,

  • reduce(R type, init R, f (R,T) -> R | abort R) R should be reduce_or_abort
  • foldf(B type, f (B,T)->B, e B) should be reduce(B type, init B, f (B,T)->B)
  • fold1(f (T,T)->T) should be reduce1(f (T,T)->T)
  • fold(m Monoid T) should be reduce(m Monoid T)

Similarly, we need a similar set for functions for Sequence.scan.

@fridis fridis added enhancement New feature or request base library related to the Fuzion base library labels Jul 5, 2024
@michaellilltokiwa michaellilltokiwa added cleanup improve code quality and removed enhancement New feature or request labels Jul 5, 2024
@maxteufel
Copy link
Collaborator

I'm not sure about this, in most languages, fold seems to be the more general variant of reduce by taking an additional accumulator parameter.

We should certainly make this more consistent though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base library related to the Fuzion base library cleanup improve code quality
Projects
None yet
Development

No branches or pull requests

3 participants