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
A lot of functions like delete require an index. A lot of times that index was not stored (which would also get updated as the array would change) but has to be refound with findIndex. When you use findIndex and immediately after use delete you know you are guaranteed an index that is not out of bounds. Could "with" functions be added that do this?
deleteWith::foralla. (a->Boolean) ->Arraya->Maybe (Arraya)
deleteWith pred array = map (\idx -> unsafeDeleteAt idx array) (findIndex pred array)
It would make sense to have the unsafe implementations for them available, at least internally in the array library #167
One could argue that if you do this you are better off using a Map. But i think people will want to use an array plenty of times anyway.
The text was updated successfully, but these errors were encountered:
flip111
changed the title
delete
deleteWith function & friends
Sep 1, 2023
At first I was going to suggest that this seems like a worse filter, but the difference is it's intended to only delete the first instance of the value matching the predicate? And return Nothing if nothing matched?
A lot of functions like delete require an index. A lot of times that index was not stored (which would also get updated as the array would change) but has to be refound with
findIndex
. When you usefindIndex
and immediately after use delete you know you are guaranteed an index that is not out of bounds. Could "with" functions be added that do this?It would make sense to have the unsafe implementations for them available, at least internally in the array library #167
One could argue that if you do this you are better off using a Map. But i think people will want to use an array plenty of times anyway.
The text was updated successfully, but these errors were encountered: