練習問題 4.5.1

filter p
foldr
の具体例として定義せよ.



filter :: (a -> Bool) -> [a] -> [a]
filter p = foldr f []
  where
    f x xs = if p x then x:xs else xs