Skip to content

Instantly share code, notes, and snippets.

@kongtomorrow
Created June 18, 2014 23:04
Show Gist options
  • Save kongtomorrow/469b352a522677b66327 to your computer and use it in GitHub Desktop.
Save kongtomorrow/469b352a522677b66327 to your computer and use it in GitHub Desktop.
func forAllCombinations<T>(r1 : Range<T>, r2 : Range<T>, body : (T, T) -> ()) {
for i in r1 {
for j in r2 {
body(i, j)
}
}
}
forAllCombinations(0..3, 0..5) {
(i, j) in
println("\(i) \(j)")
}
or
forAllCombinations(0..3, 0..5) {
println("\($0) \($1)")
}
@NorrinRadd
Copy link

Sweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment