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

feat(stdlib): Add higher order array functions #833

Merged
merged 6 commits into from
Feb 14, 2023
Merged

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Feb 13, 2023

Related issue(s)

Resolves #831

Description

Adds some higher order array functions to the stdlib.

Summary of changes

Adds:

  • std::array::map, map has been removed as we would need to support the syntax [expr; comptime expr] where we can initialize an array of any comptime length. Today it is limited to only integer literals or globals rather than any length expression.
  • std::array::fold
  • std::array::reduce - like fold but uses the first element in the array as the accumulator value.
  • std::array::find find has also been removed. The negative numbers seemed to cause issues that prevented proving/verification.
  • std::array::sort_via
  • std::array::all
  • std::array::any

Test additions / changes

Tests these functions in the higher_order_functions test.

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.
  • This PR requires documentation updates when merged.

@jfecher jfecher changed the title Add higher order array functions feat(stdlib): Add higher order array functions Feb 13, 2023
@kevaundray
Copy link
Contributor

From slack: This is blocked by 618

@jfecher
Copy link
Contributor Author

jfecher commented Feb 14, 2023

@kevaundray this is not blocked by #618, I've removed the for each loops in favor of normal for loops.

@kevaundray
Copy link
Contributor

kevaundray commented Feb 14, 2023

Ah sorry, an obvious oversight on my part, re the for loops

@jfecher jfecher added this pull request to the merge queue Feb 14, 2023
Merged via the queue into master with commit 9c62fef Feb 14, 2023
@jfecher jfecher deleted the jf/array-functions branch February 14, 2023 16:58
TomAFrench added a commit that referenced this pull request Feb 15, 2023
* master:
  chore(ssa): Predicate for store instruction (#829)
  feat(std_lib): println statements (#630)
  chore(ci): Make Kev the committer on release lockfile updates (#845)
  feat(stdlib): Add higher order array functions (#833)
  chore(ssa): Remove values from array type (#771)
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

Successfully merging this pull request may close these issues.

Add some array/iterator functions to the stdlib
2 participants