Skip to content

Instantly share code, notes, and snippets.

@rkitover
Created April 6, 2013 12:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkitover/5325910 to your computer and use it in GitHub Desktop.
Save rkitover/5325910 to your computer and use it in GitHub Desktop.
#!/bin/sh
exec scala "$0" "$@"
!#
def quicksort(l: List[Int]): List[Int] = l match {
case Nil => Nil
case p :: xs =>
val (l1, l2) = xs.partition(_ < p)
quicksort(l1) ::: p :: quicksort(l2)
}
println(quicksort(List(10,5,999,42,3,1)).mkString(" "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment