[clean-list] What am I missing ?
sebastien FURIC
sebastien.furic@tni.fr
Thu, 05 Jul 2001 17:22:41 +0200
Pieter Koopman a écrit :
> Hello Sebastien,
>
> <snip>
>
> This is a known problem. The type variable, a, in partition and partition_
> should be equal since the predicate, f, is applied to elements of the
> argument list. Currently this cannot be specified. We are working on a
> solution.
>
> For the moment you should omit the type of the local function, or pass the
> predicate, f, explicitly as argument to the local function partition_ (the
> rule lifter will add it if you don't).
> The last solution yields the definition
>
> partition :: (!a -> Bool) ![a] -> ([a], [a])
> partition f l = partition_ f l [] []
> where
> partition_ :: (!a -> Bool) ![a] [a] [a] -> ([a], [a])
> partition_ f [] accepted rejected = (accepted, rejected)
> partition_ f [x : xs] accepted rejected
> | f x = partition_ f xs [x : accepted] rejected
> | otherwise = partition_ f xs accepted [x : rejected]
>
> Have fun, Pieter Koopman
Thanks. My mind's at ease now !
Sebastien Furic