On Tuesday, January 25, 2000 10:00 AM, Joe English [SMTP:[EMAIL PROTECTED]] wrote:
> 
> Is the filter/filter definition semantically equivalent to:
> 
> partition p xs = foldr select ([],[]) xs
>     where
>     select x ~(ts,fs)   | p x       = (x:ts,fs)
>                       | otherwise = (ts, x:fs)
> 
> (that is, the current definition in the Library report
> with an extra twiddle added)?
> 
> Operationally, the 'foldr' version makes half as many
> calls to 'p' as the 'filter/filter' version, so the former
> may be preferable if the two are in fact semantically
> equivalent.
> 

I think it is better for the report to use a simple definition like filter/filter 
to illustrate the semantics. Real implemetations may then use any
more efficient definition that preserves them.

--brian

Reply via email to