Skip to content

Instantly share code, notes, and snippets.

@notyy
Created June 26, 2012 23:02
Show Gist options
  • Save notyy/2999941 to your computer and use it in GitHub Desktop.
Save notyy/2999941 to your computer and use it in GitHub Desktop.
这有多大改进?
def qsort[T <% Ordered[T]](list:List[T]):List[T] = {
list.match({
case Nil => Nil;
case x::xs =>
val (before,after) = xs.partition({ i => i.<(x) });
qsort(before).++(qsort(after).::(x)));
});
}
def qsort[T <% Ordered[T]](list:List[T]):List[T] = list match {
case Nil => Nil
case x :: xs =>
val (before, after) = xs partition ( _ < x )
qsort(before) ++ (x :: qsort(after));
}
@notyy
Copy link
Author

notyy commented Jun 26, 2012

看来还是略有改进。。。

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