Skip to content

Instantly share code, notes, and snippets.

@huydx
Last active May 12, 2020 05:52
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 huydx/039f60fe1a03154f1f9f to your computer and use it in GitHub Desktop.
Save huydx/039f60fe1a03154f1f9f to your computer and use it in GitHub Desktop.
scala interesting code
def twoPermutation[T](l: List[T)) = {
l flatMap { a =>
l flatMap { b =>
if (a==b)
Nil
else
List(a,b)
}
}
}
def twoPermutation[T](l: List[T]) = {
for {
a <- l
b <- l if a != b
} yield (a,b)
}
}
@KingHO2359
Copy link

So amazing :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment