2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -0,0 +1,15 @@
|
|||
def selectionSort[T <% Ordered[T]](list: List[T]): List[T] = {
|
||||
def remove(e: T, list: List[T]): List[T] =
|
||||
list match {
|
||||
case Nil => Nil
|
||||
case x :: xs if x == e => xs
|
||||
case x :: xs => x :: remove(e, xs)
|
||||
}
|
||||
|
||||
list match {
|
||||
case Nil => Nil
|
||||
case _ =>
|
||||
val min = list.min
|
||||
min :: selectionSort(remove(min, list))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue