apple / apple/swift-algorithms
A Method for Removing All Elements in One Array that Exist in Another
- Dominant language
- Swift
- Stars
- 6.3k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
This is a "subtract" operation, e.g.:
```
let animals = ["Cow", "Bulldog", "Labrador"]
return animals.without(["Bulldog", "Labrador"]) // ["Cow"]
```
We can see that this is an operation Swift developers are already trying to do from SO questions ([1](https://stackoverflow.com/questions/29612968/removing-objects-from-an-array-based-on-another-array), [2](https://stackoverflow.com/questions/31984435/ios-swift-remove-elements-of-an-array-from-another-array/32938861)), and it exists in other languages like [Ruby](https://ruby-doc.org/core-2.7.0/Array.html#method-i-2D).
This is a proposal to get consensus on it. And if people like it, I'd be happy to implement it.
Contributor guide
Research direction
The issue names no files or tests. Start with the proposed Array `without` operation and its linked Swift and Ruby examples; clarify the expected behavior and seek project consensus before implementation. Done means the proposal is resolved and an accepted implementation path is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100