partition1 _ [] = ([], [])
partition1 f (x:xs) =
let (ys, zs) = partition1 f xs
in if f x
then (x:ys, zs)
else (ys, x:zs)
partition2 _ [] = ([], [])
partition2 f (x:xs)
| f x = (x:ys, zs)
| otherwise = (ys, x:zs)
where (ys, zs) = partition2 f xs
main = do
print $ partition1 odd [1..6]
print $ partition2 odd [1..6]
To embed this project on your website, copy the following code and paste it into your website's HTML: