v Zip Together Two Lists - Scala

Zip Together Two Lists

If you want to learn more, check out Scala Cookbook and Programming in Scala.

Create Two Vectors

// Create two vectors
val firstName = Vector("Steve", "Bob", "Jack", "Jill")
val lastName = Vector("Jackson", "Dillan", "Bower", "Stein")

Zip Together Vectors

// Create a new variable that zips the sequences
val fullNames = firstName zip lastName
// View the zipped sequences and convert to a map
fullNames
Vector((Steve,Jackson), (Bob,Dillan), (Jack,Bower), (Jill,Stein))