The common cartesian product can be implemented as:
fun cartesian(xs, ys) =
let fun pairOne(x,[]) = []
| pairOne(x, y::ys) = [x,y]::pairOne(x,ys)
fun cart([],ys) = []
| cart(x::xs, ys) = pairOne(x, ys) @ cart(xs,ys)
in
cart(xs,ys)
end
I'm looking for a way to generate the cartesian power of grade k.
For k=2, this would output:
[[true,true],[true,false],[false,true],[false,false]]
And for k=3:
[[true,true,true],[true,true,false],[true,false,false],[false,false,false],[false,false,true],...]
Thanks