This article was forcibly made into the article on the 10th day of Swift Kotlin Lovers Association Advent Calendar 2020 w
I wanted to run the Swift Package of Swift Algorithms on Playground when writing "I touched Swift Algorithms lightly".
It seems that you can use Swift Package on Playground from Xcode 12, but it was awkward, so make a note of how to do it
Create a project with New-> Project ... This time I made it with iOS-> App.
New-> Playground ...-> Create a Playground with iOS Blank.
When saving, add it to the Project created earlier.
Add https://github.com/apple/swift-algorithms
with File-> Swift Packages-> Add Package Dependency ...
Implemented the following in Playground
import Algorithms
let numbers = [10, 20, 30, 40]
for combo in numbers.combinations(ofCount: 2) {
print(combo)
}
that's all!
Of which
Refs
Recommended Posts