Created
October 25, 2011 14:34
-
-
Save notyy/1312942 to your computer and use it in GitHub Desktop.
how to implement this in 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
quicksort' :: (Ord a) => [a] -> [a] | |
quicksort' [] = [] | |
quicksort' (x:xs) = smaller ++ [x] ++ bigger | |
where smaller = quicksort' $ filter (<=x) xs | |
bigger = quicksort' $ filter (>x) xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
solved, thanks老猪
def quicksort[T : Ordering](l: List[T]) : List[T] = l match {
case Nil => Nil
case x :: xs =>
val ord = Ordering[T]
import ord._
}