summaryrefslogtreecommitdiff
path: root/sources/examples/sort1.scala
diff options
context:
space:
mode:
Diffstat (limited to 'sources/examples/sort1.scala')
-rw-r--r--sources/examples/sort1.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/sources/examples/sort1.scala b/sources/examples/sort1.scala
new file mode 100644
index 0000000000..f2722b23cc
--- /dev/null
+++ b/sources/examples/sort1.scala
@@ -0,0 +1,12 @@
+import scala._;
+
+module sorter {
+
+ def sort(a: List[Int]): List[Int] = {
+ val pivot = a at (a.length / 2);
+ sort(a.filter(x => x < pivot))
+ ::: a.filter(x => x == pivot)
+ ::: sort(a.filter(x => x > pivot))
+ }
+
+} \ No newline at end of file