I coded a function to enumerate all permutations of a given list. What do you think of the code below?
def interleave(x:Int, l:List[Int]):List[List[Int]] = {
Here is a version based on span.
def perms[T](xs: List[T]): List[List[T]] = xs match { case List(_) => List(xs) case _ => for ( x <- xs ; val (l, r) = xs span { x!= } ; ys <- perms(l ++ r.tail) ) yield x :: ys }