Implement scala merge operator for two List
Sigiloso
def merge(ls1: List[Int], ls2: List[Int]): List[Int] = { def fun(ls1: List[Int], ls2: List[Int], res: List[Int]): List[Int] = (ls1, ls2) match { case (Nil, _) => res ++ ls2 case (_, Nil) => res ++ ls1 case (p::q, r::s) => p fun(q, ls2, res :+ p) case false => fun(ls1, s, res :+ r) } } fun(ls1, ls2, List[Int]()) }