I want to create a generic permutations
function.
def permutation(size: Int): Stream[List[Int]] = ...
permutation(1) # same as: for { x <- (1 to 10).toStream } yield List(x)
permutation(2) # same as: for { x <- (1 to 10).toStream;
y <- (1 to 10).toStream; } yield List(x,y)
Can I get dynamically nested for-comprehensions behavior on the fly for arbitrary depth
.
I think this gives a generalised version of what you are asking for:
Example usages: