Created
March 7, 2018 03:33
-
-
Save HYChou0515/10fcb861583adb853f9832b172827908 to your computer and use it in GitHub Desktop.
unique sort using scala
This file contains 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
//unique sort using scala | |
object Main extends App { | |
val array=Array(5,4,7,6,5,5,4,3,3,3,2,5,5,1,2) | |
util.Sorting.quickSort(array) | |
val newArray = array.foldRight(List.empty[Int]){ | |
case (a, b) => | |
if (!b.isEmpty && b(0) == a) | |
b | |
else | |
a :: b | |
} | |
for(s <- newArray) println(s) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment