Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,15 @@
import scala.compat.Platform
object Sort_an_integer_array extends App {
val array = Array((for (i <- 0 to 10) yield scala.util.Random.nextInt()):
_* /*Sequence is passed as multiple parameters to Array(xs : T*)*/)
/** Function test the array if it is in order */
def isSorted[T](arr: Array[T]) = array.sliding(2).forall(pair => pair(0) <= pair(1))
assert(!isSorted(array), "Not random")
scala.util.Sorting.quickSort(array)
assert(isSorted(array), "Not sorted")
println(s"Array in sorted order.\nSuccessfully completed without errors. [total ${Platform.currentTime - executionStart} ms]")
}

View file

@ -0,0 +1,2 @@
println(List(5,2,78,2,578,-42).sorted)
//--> List(-42, 2, 2, 5, 78, 578)

View file

@ -1,2 +0,0 @@
println(List(5,2,78,2,578,-42).sortWith(_<_))
//--> List(-42, 2, 2, 5, 78, 578)