List filter (source code)

= List filter
{title2=`filter :: (a -> Bool) -> [a] -> [a]`}

Keep exactly the elements of a <list> satisfying a <predicate>, preserving their relative order. A recursive step tests the head, prepending it to the filtered tail when it passes and otherwise returning that filtered tail alone. On a finite input, this uses one predicate evaluation per element; an infinite rejected tail cannot produce a next output under <lazy evaluation>.