Back to Fpinscala

14.Answer

answerkey/datastructures/14.answer.md

latest253 B
Original Source
scala
/*
`append` simply replaces the `Nil` constructor of the first list with the second list, which is exactly the operation
performed by `foldRight`.
*/
def appendViaFoldRight[A](l: List[A], r: List[A]): List[A] =
  foldRight(l, r, Cons(_,_))