Domanda di colloquio di TechSophy

Implement scala zipper method

Risposta di colloquio

Anonimo

14 mag 2020

def zip(ls1: List[Int], ls2: List[String]): List[(Int, String)] = { def fun(ls1: List[Int], ls2: List[String], res: List[(Int, String)]): List[(Int, String)] = (ls1, ls2) match { case (Nil, _) => res case (_, Nil) => res case (p::q,r::s) => (fun(q,s, res :+ (p,r))) } fun(ls1, ls2, List[(Int, String)]()) }