Skip to content
Snippets Groups Projects
Commit 8f918dc1 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

[project @ 2000-08-29 16:35:56 by simonpj]

Add filterFB comment
parent 3e790230
No related merge requests found
% ------------------------------------------------------------------------------
% $Id: PrelList.lhs,v 1.20 2000/06/30 13:39:35 simonmar Exp $
% $Id: PrelList.lhs,v 1.21 2000/08/29 16:35:56 simonpj Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -130,6 +130,15 @@ filterFB c p x r | p x = x `c` r
"filterList" forall p. foldr (filterFB (:) p) [] = filterList p
#-}
-- Note the filterFB rule, which has p and q the "wrong way round" in the RHS.
-- filterFB (filterFB c p) q a b
-- = if q a then filterFB c p a b else b
-- = if q a then (if p a then c a b else b) else b
-- = if q a && p a then c a b else b
-- = filterFB c (\x -> q x && p x) a b
-- I originally wrote (\x -> p x && q x), which is wrong, and actually
-- gave rise to a live bug report. SLPJ.
filterList :: (a -> Bool) -> [a] -> [a]
filterList _pred [] = []
filterList pred (x:xs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment