3
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))
我不能肯定列表[A]在foldLeft如何爲B型的人可以清除過程中該功能發生了什麼?扭轉階使用foldLeft