S SmartDocs
Serie: haskell haskell 8 líneas · Actualizado 2026-02-03

exercise_5_1.hs

haskell/Week_6_Lab/exercise_5_1.hs

-- Define the unMaybe function
unMaybe :: [Maybe a] -> [a]
unMaybe [] = []  -- Base case: empty list returns an empty list
unMaybe (x:xs) =
  case x of
    Just value -> value : unMaybe xs  -- If the element is Just, extract the value and continue
    Nothing    -> unMaybe xs          -- If the element is Nothing, skip it and continue
    

Artículos relacionados