Last active
May 12, 2020 05:52
-
-
Save huydx/039f60fe1a03154f1f9f to your computer and use it in GitHub Desktop.
scala interesting code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So amazing :))