Consider the following Swift code.
var a = [(1, 1)]
if contains(a, (1, 2)) {
println(\"Yes\")
}
All I need is to check if a
Add the following to your code:
func contains(a:[(Int, Int)], v:(Int,Int)) -> Bool {
let (c1, c2) = v
for (v1, v2) in a { if v1 == c1 && v2 == c2 { return true } }
return false
}
Swift is not that flexible when it comes to tuples. They do not conform to the Equatable
protocol. So you must define that or use the above function.