3 ms·
Not specifically "software" but this piece of Haskell code is the most beautiful code I've ever seen: quicksort [] = [] quicksort (x:xs) = quicksort [y
by jaybosamiya 11y ago
Not specifically "software" but this piece of Haskell code is the most beautiful code I've ever seen:
quicksort [] = []
quicksort (x:xs) = quicksort [y|y<-xs,y<x] ++ [x] ++ quicksort [y|y<-xs,y>=x]
- cyphar 11y agoThe recursive Fibonacci definition in Haskell is far more beautiful IMO. But there's always more beautiful one-line snippets (like the regex that can tell you if a number is prime). fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
- CyberDildonics 11y agoWill you still think that when you realize it isn't actually a quicksort?
- eru 11y agoIt's tree sort. It does the same comparisons as quicksort, but organizes its data differently. It's nifty, but not an especially beautiful use of Haskell. Okasaki's Red-Black Trees rendered in Haskell are nicer, for example.