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