Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,7 +1,7 @@
import Data.List (unfoldr)
selectionSort = unfoldr selectionSort' where
selectionSort' [] = Nothing
selectionSort' (first:lst) = Just $ foldl f (first, []) lst
f (small, output) x | x < small = (x, small:output)
| otherwise = (small, x:output)
selSort :: (Ord a) => [a] -> [a]
selSort [] = []
selSort xs = let x = maximum xs in selSort (remove x xs) ++ [x]
where remove _ [] = []
remove a (x:xs)
| x == a = xs
| otherwise = x : remove a xs