S SmartDocs
Serie: haskell haskell 6 righe · Aggiornato 2026-02-03

exercise_3.hs

haskell/Week_6_Lab/exercise_3.hs

-- Define the myFilter function
myFilter :: (a -> Bool) -> [a] -> [a]
myFilter _ [] = []  -- Base case: if the list is empty, return an empty list
myFilter f (x:xs)
  | f x       = x : myFilter f xs  -- If the function evaluates to True, include the element
  | otherwise = myFilter f xs      -- Otherwise, skip the element

Articoli correlati