Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Elegance of Haskell

Name: Anonymous 2016-10-23 8:03

quicksort [] = []
quicksort (x:xs) = quicksort small ++ (x : quicksort large)
where small = [y | y <- xs, y <= x]
large = [y | y <- xs, y > x]

Name: Anonymous 2016-10-23 21:19

>>12

Make that O(n^2) because of the crappy choice of the pivot. (The first element).

The problem with these 'elegant' implementations is, is that they aren't really solving the problem at hand, e.g. sorting the list efficiently.

Also using haskell, one would use a tree sort instead of a quicksort implemented with a hylomorphism, so the intermediate structure is only virtual.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List