-5

I have two lists, List(1,2),List(3,4)

and I want Two-dimensional List(List(1,2),List(3,4)) like this,how?

Chaitanya
  • 3,590
  • 14
  • 33

2 Answers2

1

Is this what you mean?

val a = List(1,2)
val b = List(3,4)
val c = List(a,b) // List(List(1,2),List(3,4))
Dionysis Nt.
  • 955
  • 1
  • 6
  • 16
0

if you really want a List of Lists then @Dionysis answer is ok. You can use

  val a = List(1,2)
  val b = List(3,4)
  a.zip(b) //res0: List[(Int, Int)] = List((1,3), (2,4))

if you don´t need that type

Pedro Correia Luís
  • 1,085
  • 6
  • 16