all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
def swap(a: Array[Int], i1: Int, i2: Int) = { val tmp = a(i1); a(i1) = a(i2); a(i2) = tmp }
|
||||
|
||||
def selectionSort(a: Array[Int]) =
|
||||
for (i <- 0 until a.size - 1)
|
||||
swap(a, i, (i + 1 until a.size).foldLeft(i)((currMin, index) =>
|
||||
if (a(index) < a(currMin)) index else currMin))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
def selectionSort(a: Array[Int]) = for (i <- 0 until a.size - 1) (
|
||||
{ (i1: Int, i2: Int) => val tmp = a(i1); a(i1) = a(i2); a(i2) = tmp }
|
||||
) (i, (i + 1 until a.size).foldLeft(i)((currMin, index) => if (a(index) < a(currMin)) index else currMin) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue