Quizzes
Site Language: English
Українська
English
Русский
Programming Tests
Login
Sign Up
Programming Tests
Theory
Snippets
Papers
Landing
Android
Prices
FAQ
Cosmo Story
Terms and Conditions
Privacy Policy
Cookies Policy
Send Feedback
list
:
Content language: English
Русский
What is the result of code execution? def init[A](l: List[A]): List[A] = l match { case Nil => sys.error("init of empty list") case Cons(_, Nil) => Nil case Cons(h, t) => Cons(h, init(t)) } init(List(1, 2, 3)) Assuming the following code is available for your reference sealed trait List[+A] case object Nil extends List[Nothing] case class Cons[+A](head: A, tail: List[A]) extends List[A]
list
What is the result of code execution? def init[A](l: List[A]): List[A] = l match { case Nil => sys.error("init of empty list") case Cons(_, Nil) => Nil case Cons(h, t) => Cons(h, init(t)) } init(List(1)) Assuming the following code is available for your reference sealed trait List[+A] case object Nil extends List[Nothing] case class Cons[+A](head: A, tail: List[A]) extends List[A]
list
What will be the result of comparing Lists using eq function? val a = List(1, 2, 3) val b = List(1, 2, 3) a eq b
list
What will be the result of comparing Lists using == function? val a = List(1, 2, 3) val b = List(1, 2, 3) a == b
list
What will be the result of comparing empty lists (Nil)? val a: List[String] = Nil val b: List[Int] = Nil a == Nil // 1 a eq Nil // 2 b == Nil // 3 b eq Nil // 4 a == b // 5 a eq b // 6
list
← Prev
1
2
3
4
Next →
Sign Up Now
or
Subscribe for future quizzes