Closed jvoigtlaender closed 8 years ago
Also, there's "removeAt", which might as well be called "deleteAt". The library could use a pass of making names consistent.
The last comment, because there are also a bunch of "drop..." functions. What is the difference between deleting, removing, and dropping?
Edit: now that this issue is closed, I've cleaned up the following list to make it easier to refer back to.
If the goal is to go for consistent naming, then to me:
My deleteFirst
(https://github.com/elm-community/list-extra/pull/6) operates on the first matching element, but that's just copying a Haskell convention. To my ear "delete" connotes erasing data from persistent storage, rather than merely discarding it from a data structure in memory. I'd prefer to clean up the other names and rename it to remove
.
I would suggest:
removeAt
because it fits this constraint. removeWhen
to filterNot
(or drop it entirely because it's trivial).deleteIf
because it's the same as filterNot
.deleteFirst
to remove
, which is consistent with Set.remove
What about the function currently called dropDuplicates?
And I assume there would be renaming of current dropWhileEnd to dropWhileRight, and analogously for takeWhileEnd?
I think that makes sense. Re: dropDuplicates
, I'm inclined to think of it in terms of what you get back - how about uniques
?
Happy to put these changes in my PR.
In my nonempty list library, I offer uniq
and dedup
. The former removes all duplicates, while the latter removes adjacent duplicates. I'm not thrilled with the abbreviations, but maybe unique
, as a verb, rather than the plural noun?
Yeah, sounds good. Updated #6.
Some context about dropDuplicates/unique: https://github.com/elm-community/elm-list-extra/issues/31.
Also, a change here affects https://github.com/elm-community/list-extra/pull/5, so bring this name change up there as well?
deleteIf
andremoveWhen
are the same function. I think the library should contain only one of them.