"Premature Optimization is Root of All Evil." - Donald E.Knuth
qsort [] = [] qsort (lst) = ((qsort lesser) ++ mid ++ (qsort greater)) where p = head lst lesser = [z | z<-lst, z<p] greater = [z | z<-lst, z>p] mid = [z | z<-lst, z==p] main :: IO() main = do putStrLn $ show (qsort [2,7,3,5,1])
No comments:
Post a Comment