Skip to content

Instantly share code, notes, and snippets.

@Nub
Created June 18, 2014 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nub/f1b6b2ce38a3b92b515c to your computer and use it in GitHub Desktop.
Save Nub/f1b6b2ce38a3b92b515c to your computer and use it in GitHub Desktop.
// Playground - noun: a place where people can play
import Cocoa
let a = [0..5, 0..5]
func conjugate(sets: Array<Range<Int>>) -> Array<(Int, Int)> {
var conjugates = Array<(Int, Int)>()
for setA: Range<Int> in sets {
for setB: Range<Int> in sets {
// Not sure why this operator doesn't exist yet
// if setA === setB { continue }
for i in setA {
for j in setB {
conjugates += (i, j)
}
}
}
}
return conjugates
}
let b = conjugate(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment