Last active
August 29, 2015 14:07
-
-
Save jarsen/bc8ee2a9cc7d28e8d1c4 to your computer and use it in GitHub Desktop.
how can I bind to a tuple in the closure?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func meanSquaredError(predictions: [Double], values: [Double]) -> Double { | |
let sum = reduce(Zip2(predictions, values), 0.0) { (acc, y) in | |
let diff = y.0 - y.1 | |
return acc + (diff * diff) | |
} | |
return sum / Double(predictions.count) | |
} | |
// what I want is to bind the arguments in the closure to (acc, (yHat, y)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment