Can anybody see light on this bug? The playground insists that argument #2 is missing, but there is no argument #1!
The intention of the code to to count the number of runs of a equatable value, and return a sequence of tuples consisting of the values and their counts. I've worked on this code extensively, optimising it and refining it until I'm pretty sure that it should work… but although it compiles, I cannot call it the way it was intended.
The error i get from calling the code below is missing argument for parameter #2 in call
extension SequenceOf {
func CountRuns<T: Equatable>() -> SequenceOf<(T, Int)> {
return SequenceOf<(T, Int)>([])
return SequenceOf<(T, Int)> { () -> GeneratorOf<(T, Int)> in
var generator = self.generate()
var previousValue: T?
var start = true
return GeneratorOf<(T, Int)> { () -> (T, Int)? in
var count = 1
var retValue: (T, Int)?
while(true) {
var value = generator.next() as T?
if start {
previousValue = value
start = false
} else if value != nil && value! == previousValue! {
count++
} else {
if previousValue != nil {
retValue = (previousValue!, count)
}
previousValue = value
break
}
}
return retValue
}
}
}
}
println(SequenceOf(y).CountRuns())
Playground execution failed: <EXPR>:327:23: error: missing argument for parameter #2 in call
println(SequenceOf(y).CountRuns())
^