Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Scala

Idiom #166 Concatenate two lists

Create the list ab containing all the elements of the list a, followed by all the elements of the list b.

val ab = a ++ b
val ab = a ::: b

::: is specific to List.

Both a and b must be of type List.

::: is more efficient than ++ when concatenating more than 2 lists.
(def ab (concat a b))

New implementation...