scala-codesheet-api icon indicating copy to clipboard operation
scala-codesheet-api copied to clipboard

pattern match / toString wtf

Open MasseGuillaume opened this issue 12 years ago • 0 comments

def quicksort(a: List[Int] = List(3,4,5,23,1,2,3,4)): List[Int] = {
    if(a.isEmpty) Nil
    else {
        val (big, small) = a.tail.partition(_ > a.head)
        quicksort(small) ::: (a.head :: quicksort(big))
    }
}
quicksort(a = List(3, 4, 5, 23, 1, 2, 3, 4)) => else => {
    x$1 = (List(4, 5, 23, 4),List(1, 2, 3)); big = List(4, 5, 23, 4); small = List(1, 2, 3)
    {x$3 = List(1, 2, 3); List(1, 2, 3, 3, 4, 4, 5, 23)}
}

MasseGuillaume avatar Nov 06 '13 08:11 MasseGuillaume