I think a specification

>     any p = or . map p

is much more concise than the implementation

>     any p []     = False
>     any p (x:xs) = p x || any p xs


another reason to prefer the higher-level variant
is that the compiler can apply fusion laws, as in

any p . map f = or . map p . map f = or . map (p . f)

(one could also do this starting from the second definition,
but then the compiler's first step would be to derive the
higher-level version from it, I guess)

so it's not at all clear that the above implementation
is indeed more efficient.


I'd rather write clear code, than worry about efficiency too early.
Who said this, "premature optimization is the root of all evil".


best regards
-- 
-- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ --
-- [EMAIL PROTECTED] -- phone/fax (+49) 341 9732 204/252 --

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to