Home > front end >  How to achieve the below sequence?
How to achieve the below sequence?

Time:10-16

How to achieve result sequence with the given 2 sequences ?

val seq1 = Seq("A","B","C")
val seq2 = Seq(1,2,3)

val Result = Seq("A1","A2","A3","B1", "B2", "B3", "C1", "C2", "C3")

CodePudding user response:

You can just use for comprehensions to find all combinations and concat the result into string:

val seq1 = Seq("A", "B", "C")
val seq2 = Seq(1, 2, 3)

val Result = for {
  s1 <- seq1
  s2 <- seq2
} yield s1   s2
  • Related