Eccentric Developments


Quicksort in Nim

import sequtils

proc quickSort(arr: seq[int]): seq[int] =
    if arr.len == 0: return @[]
    let pivot = arr[0]
    let smaller = arr[1..^1].filterIt(it <= pivot)
    let bigger = arr.filterIt(it > pivot)
    concat(smaller.quickSort, @[pivot], bigger.quickSort)
Enrique CR - 2018-02-06