Difference between revisions of "User talk:Marcelo.parrela"
Jump to navigation
Jump to search
(→Quicksort - An other Implementation: new section) |
|||
Line 1: | Line 1: | ||
− | <pre> |
||
− | -- by Marcelo Parrela (marcelo.parrela@gmail.com) |
||
− | quicksort' [] = [] |
||
− | quicksort' (a:as) = quicksort' l1 ++ a : quicksort' l2 |
||
− | where |
||
− | (l1,l2) = separate as a [] [] |
||
− | |||
− | separate [] _ a b = (a,b) |
||
− | separate (l:ls) a l1 l2 |
||
− | | l <= a = separate ls a l1' l2 |
||
− | | otherwise = separate ls a l1 l2' |
||
− | where |
||
− | l1' = l1++[l] |
||
− | l2' = l2++[l] |
||
− | </pre> |
||
− | |||
== Quicksort - An other Implementation == |
== Quicksort - An other Implementation == |
||
Latest revision as of 12:21, 14 October 2013
Quicksort - An other Implementation
-- by Marcelo Parrela (marcelo.parrela@gmail.com) quicksort' [] = [] quicksort' (a:as) = quicksort' l1 ++ a : quicksort' l2 where (l1,l2) = separate as a [] [] separate [] _ a b = (a,b) separate (l:ls) a l1 l2 | l <= a = separate ls a l1' l2 | otherwise = separate ls a l1 l2' where l1' = l1++[l] l2' = l2++[l]