Advertisement
clairec

bottom up vs top down

Sep 14th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. quicksort :: (Ord a) => [a] -> [a]
  2. quicksort [] = []
  3. quicksort (x:xs) =
  4.     let smallerSorted = quicksort [a | a <- xs, a <= x]
  5.         biggerSorted  = quicksort [a | a <- xs, a > x]
  6.     in  smallerSorted ++ [x] ++ biggerSorted
  7.  
  8.  
  9. quicksort :: (Ord a) => [a] -> [a]
  10. quicksort [] = []
  11. quicksort (x:xs) = smallerSorted ++ [x] ++ biggerSorted
  12.     where smallerSorted = quicksort [a | a <- xs, a <= x]
  13.           biggerSorted  = quicksort [a | a <- xs, a > x]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement