Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,4 +1,6 @@
|
|||
def insert(list: List[Int], value: Int) = list.span(_ < value) match {
|
||||
case (lower, upper) => lower ::: value :: upper
|
||||
def insertSort[X](list: List[X])(implicit ord: Ordering[X]) = {
|
||||
def insert(list: List[X], value: X) = list.span(x => ord.lt(x, value)) match {
|
||||
case (lower, upper) => lower ::: value :: upper
|
||||
}
|
||||
list.foldLeft(List.empty[X])(insert)
|
||||
}
|
||||
def insertSort(list: List[Int]) = list.foldLeft(List[Int]())(insert)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue