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

Add array manipulation functions #629

Merged
merged 7 commits into from
Dec 16, 2024

Conversation

hdwalters
Copy link
Contributor

@hdwalters hdwalters commented Dec 5, 2024

Implements some standard library functions that allow to manipulate arrays:

  1. first(array) to get the first element (merely a shorthand for array[0])
  2. last(array) to get the last element (merely a shorthand for array[len(array) - 1])
  3. remove_at(array, index) to remove an element at the index, translates to unset array[index]
  4. extract_at(array, index) — same as remove_at, but also returns the element
  5. pop(array) — remove and return the last element
  6. shift(array) — remove and return the first element

@Mte90
Copy link
Member

Mte90 commented Dec 12, 2024

Now the test suite is working :-)

@hdwalters hdwalters force-pushed the array-manipulation-functions branch from 84b5966 to 5a9cc2a Compare December 12, 2024 18:15
src/std/array.ab Outdated Show resolved Hide resolved
@hdwalters hdwalters force-pushed the array-manipulation-functions branch from 9d0504b to 7afc4f3 Compare December 14, 2024 16:36
Copy link
Member

@mks-h mks-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some notes, otherwise approved.

src/std/array.ab Outdated Show resolved Hide resolved
src/tests/stdlib/array_remove_each.ab Outdated Show resolved Hide resolved
@Mte90 Mte90 merged commit 79fa51c into amber-lang:master Dec 16, 2024
1 check passed
@hdwalters hdwalters deleted the array-manipulation-functions branch December 18, 2024 22:14
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.

4 participants