# Haskell Filter Implementation

myFilter :: (a -> Bool) -> [a] -> [a]
myFilter fn [] = []
myFilter fn (x:xs)
  | fn x      = x : myFilter fn xs
  | otherwise = myFilter fn xs

main = do
  putStrLn "Filter implementation"
  
  let numbers = [1, 2, 3, 4, 5]
  
  print $ myFilter odd numbers
  print $ myFilter (\x -> mod x 2 == 1) numbers

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: