Q:

For Expression with recursive generator

In the 3 code variations below, the For Expression produces totally different output. The recursive generator seems to be sourced from real values (A,B,C) but in version2 and version3 of the function below, none of the letters were present in the yield output. What is the reason?
def permuteV1(coll:List[Char]) : List[List[Char]] = {
  if (coll.isEmpty) List(List())
  else {
    for {
      pos <- coll.indices.toList
      elem <- permuteV1(coll.filter(_ != coll(pos)))
    } yield coll(pos) :: elem
  }
}
permuteV1("ABC".toList)
//res1: List[List[Char]] = List(List(A, B, C), List(A, C, B), List(B, A, C), List(B, C, A), List(C, A, B), List(C, B, A))

def permuteV2(coll:List[Char]) : List[List[Char]] = {
  if (coll.isEmpty) List(List())
  else {
    for {
      pos <- coll.indices.toList
      elem <- permuteV2(coll.filter(_ != coll(pos)))
    } yield elem
  }
}
permuteV2("ABC".toList)
//res2: List[List[Char]] = List(List(), List(), List(), List(), List(), List())

def permuteV3(coll:List[Char]) : List[List[Char]] = {
  if (coll.isEmpty) List(List())
  else {
    for {
      pos <- coll.indices.toList
      elem <- permuteV3(coll.filter(_ != coll(pos)))
    } yield '-' :: elem
  }
}
permuteV3("ABC".toList)
//res3: List[List[Char]] = List(List(-, -, -), List(-, -, -), List(-, -, -), List(-, -, -), List(-, -, -), List(-, -, -))

A:

In all three examples elem is the empty List().  When you walk through the recursions you'll see it is the only result possible.
In the 1st case you pre-pend a meaningful value to the empty elem.  Those values are saved on the stack and collected when the recursion has reached its conclusion and the stack is unwound.
A different way to get the same result: "ABC".toList.permutations.toList

