練習問題 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
filter pを
foldrの具体例として定義せよ.
filter :: (a -> Bool) -> [a] -> [a]
filter p = foldr f []
where
f x xs = if p x then x:xs else xs