To 
| > partition _ []     = ([],  [])
| > partition p (x:xs) = if p x then (x:ys, zs) else (ys, x:zs)
| >     where (ys, zs) = partition p xs
| >
| > runs your example in constant space.


Joe Fasel <[EMAIL PROTECTED]>  writes

> This probably works fine for many applications, but of course,
> it is a different function.  What applications of partition need
> to preserve list order?


"Different function" - to what?
This defines the same map as the Standard Library description does:
\p xs -> (filter p xs, filter (not .p) xs). 


------------------
Sergey Mechveliani
[EMAIL PROTECTED]

Reply via email to