Comments (7)
Couldn't repro this, did this have another detail for the repro?
from swift-algorithms.
Odd. It's still happening for me. I copied AdjacentPairsTests.swift
and TestUtilities.swift
into my project and updated the testThreeElementSequence()
test.
func testThreeElementSequence() {
let pairs = (0...).prefix(3).adjacentPairs()
XCTAssertEqualSequences(pairs, [(0, 1), (1, 2)], by: ==)
+ let pairs2 = [0, 1, 2].adjacentPairs().map {x in x}
+ XCTAssertEqualSequences(pairs2, [(0, 1), (1, 2)], by: ==)
}
Perhaps related, [0, 1, 2].adjacentPairs()
without the .map {x in x}
fails to type check with Ambiguous use of 'adjacentPairs()'
.
Any suggestions?
from swift-algorithms.
Wait, do the "ambiguos" diagnostic notes point to the candidates it found, it looks like maybe you would have to versions of "adjacentPairs" and the one being pick for array is incorrect. You can also click in Xcode and see where it takes you.
from swift-algorithms.
You're right! I'm new to Swift but should have checked this first anyway, sorry. It looks like SwifterSwift defines a different version of adjacentPairs
. I haven't yet narrowed down how the two implementations are causing incorrect results though.
from swift-algorithms.
Coincidently I happen to be a maintainer of SwifterSwift so I can take a look on the implementation there and see if this is indeed a bug there. Thank you for the report :)
from swift-algorithms.
Seems to be the intended behavior:
/// SwifterSwift: Unique pair of elements in a collection.
///
/// let array = [1, 2, 3]
/// for (first, second) in array.adjacentPairs() {
/// print(first, second) // print: (1, 2) (1, 3) (2, 3)
/// }
///
///
Seems to be what swift-algorithms
calls permutations
.
from swift-algorithms.
Seems to be what
swift-algorithms
callspermutations
.
Yeah, this is actually something I've missed on review
from swift-algorithms.
Related Issues (20)
- Binary search function for collection or array HOT 2
- Unique combinations from a collection HOT 1
- Consider using @discardableResult where possible. HOT 2
- `uniqued(on:)` is missing a `uniquingWith` overload.
- Xcode 14 & iOS 16 compile errors HOT 14
- Using combinations in a Playground HOT 3
- The `merge` algorithm for combining sorted collections is missing. HOT 1
- Consider adding a function that creates a string representation of a collection similar to Scala's mkString
- Strange performance decline of nested `chain()` application
- Apple is at least as racist as the rest of the tech industry
- Graph Structure HOT 2
- Adding a CompactedCollection to an Array triggers EXC_BAD_ACCESS HOT 12
- Consider add a transpose/rotate function for 2D arrays
- Conditionally conform Chain2Sequence to MutableCollection HOT 1
- Doc for `partitioningIndex` doesn't mention preconditions on the `self` collection. HOT 2
- `CombinationsSequence` should be a `Collection` HOT 2
- [FR]: Support Apple Privacy Manifest HOT 1
- app
- How can I contribute to this project?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-algorithms.