Here's an algorithm to generate the cartesian product of two sets in Swift using iteration:
main.swift235 chars10 linesYou can call the function like this:
main.swift171 chars5 linesThe output is a set of sets where each inner set represents a cartesian product of elements from set a and set b.
gistlibby LogSnag