-- positions 0 [1,0,0,1,0] => [1,2,4]
-- positions 1 [1,0,0,1,0] => [0,3]
-- positions 'a' "alabama" => [0,2,4,6]
positions :: Eq a => a -> [a] -> [Int]
positions a as = [i | (y, i) <- zip as [0..], a == y]
count c s = length [undefined | i <- s, i == c]
qsort :: (Ord a) => [a] -> [a]
-- qsort [] = []
-- qsort (x:xs) = qsort smaller ++ [x] ++ qsort larger
-- where smaller = [i | i <- xs, i < x]
-- larger = [i | i <- xs, i > x]
qsort [] = []
qsort (x:xs) = qsort [i | i <- xs, i < x]
++ [x] ++
qsort [i | i <- xs, i > x]
swap (x,y) = (y,x)