apple / apple/swift-algorithms
Provide a version of interspersed that accepts a closure.
- Dominant language
- Swift
- Stars
- 6.3k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
When doing macOS or iOS programming, a common use-case I have for `interspersed` is to insert a separator or divider view in-between a bunch of other views.
Example, given an array of views, I'd like to insert a separator view in-between each one:
```
let views = [view1, view2, view3]
let allViews = views.interspersed(using: { SeparatorView() })
```
Expected:
`[view1, separator1, view2, separator2, view3]
`
Because these are NSView, the inserted element needs to be a new instance each time, which the existing implementation does not appear to offer.
Contributor guide
Research direction
Start by locating the existing interspersed implementation and its tests in the swift-algorithms repository. Add coverage for a closure-based form that creates a distinct separator between adjacent views, and confirm the expected sequence for three input elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100