func perms(var ar: [T]) -> [[T]] { return heaps(&ar, ar.count) } func heaps(inout ar: [T], n: Int) -> [[T]] { return n == 1 ? [ar] : Swift.reduce(0..