1
class IntList(val hd: Int, val tl: IntList)
2
object NilIL extends IntList(0, null)
4
def unapply(il: IntList): Option[(Int, IntList)] = if(il eq NilIL) None else Some(il.hd, il.tl)
5
def apply(x: Int, xs: IntList) = new IntList(x, xs)
8
object Test extends App {
9
IntList(1, IntList(2, NilIL)) match {
10
case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3)
11
case IntList(x, y) => println(x)
14
IntList(1, IntList(2, IntList(3, NilIL))) match {
15
case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3)
16
case IntList(x, y) => println(x)
20
// ((x1: IntList) => IntList.unapply(x1).flatMap(((x4: (Int, IntList)) => IntList.unapply(x4._2).flatMap(((x5: (Int, IntList)) => IntList.unapply(x5._2).flatMap(((x6: (Int, IntList)) => implicitly[Predef.MatchingStrategy[Option]].success(Predef.println(x4._1.+(x5._1).+(x6._1))))))))).orElse(IntList.unapply(x1).flatMap(((x7: (Int, IntList)) => implicitly[scala.Predef.MatchingStrategy[Option]].success(Predef.println(x7._1))))).orElse(implicitly[scala.Predef.MatchingStrategy[Option]].fail))(IntList.apply(1, IntList.apply(2, IntList.apply(3, null))))
24
IntList.this.unapply(x1).flatMap[Int](((x4: (Int, IntList)) =>
25
IntList.this.unapply(x4._2).flatMap[Int](((x5: (Int, IntList)) =>
26
IntList.this.unapply(x5._2).flatMap[Int](((x6: (Int, IntList)) =>
27
Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x6._1))))))).orElse[Int](
28
IntList.this.unapply(x1).flatMap[Int](((x7: (Int, IntList)) =>
29
Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x7._1)))).orElse[Int](
30
Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).fail)
31
).apply(IntList.apply(1, null))
b'\\ No newline at end of file'