def foldLeft[A, B] (as: List[A], z: B) (f: (B, A) => B) : B = as match {
case Nil => z
case Cons(x, xs) => foldLeft(xs, f(z, x))(f)
}
def reverse[A] (as: List[A]): List[A] =
foldLeft(as, List[A]())((h, acc) => Cons(acc, h))
Je ne suis pas sûr comment List [A] dans foldLeft est de type B. Quelqu'un peut-il effacer le processus qui se passe dans cette fonction?inverser en utilisant foldLeft dans scala