Skip to content

Instantly share code, notes, and snippets.

@noahlz
Created March 25, 2015 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahlz/3391c40988843f870c24 to your computer and use it in GitHub Desktop.
Save noahlz/3391c40988843f870c24 to your computer and use it in GitHub Desktop.
scala> val x = 1 :: 2 :: 3 :: Nil
x: List[Int] = List(1, 2, 3)
scala> val y = 1 :: 2 :: 4 :: Nil
y: List[Int] = List(1, 2, 4)
scala> x union y
res1: List[Int] = List(1, 2, 3, 1, 2, 4)
scala> res1.distinct
res2: List[Int] = List(1, 2, 3, 4)
scala> y union x
res3: List[Int] = List(1, 2, 4, 1, 2, 3)
scala> res3.distinct
res4: List[Int] = List(1, 2, 4, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment