Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Scala Online

object HelloWorld {
    def main(args: Array[String]) {
        println(zipWith(List(1,2,3,4,5,6),List(1,2,3,4,5,6),(x: Int, y: Int) => x+y))
        
        def zipWith[A,B,C](xs: List[A], ys: List[B], f: (A, B) => C): List[C] = {
            val list = xs.zip(ys)
            for (el <- list) yield f(el._1,el._2)
        }
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.