シリーズ: haskell
haskell
7 行
· 更新日 2026-02-03
exercise_5_2.hs
haskell/Week_6_Lab/exercise_5_2.hs
-- Define the mapMaybe function
mapMaybe :: (a -> b) -> [Maybe a] -> [b]
mapMaybe _ [] = [] -- Base case: empty list returns an empty list
mapMaybe f (x:xs) =
case x of
Just value -> f value : mapMaybe f xs -- Apply the function to the value inside Just and continue
Nothing -> mapMaybe f xs -- Skip Nothing values and continue
関連記事
haskell
haskell
更新日 2026-02-03
Adding.hs
Adding.hs — haskell source code from the haskell learning materials (haskell/Adding.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Area.hs
Area.hs — haskell source code from the haskell learning materials (haskell/Area.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Chess.hs
Chess.hs — haskell source code from the haskell learning materials (haskell/Chess.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the haskell learning materials (haskell/ChessGraphics.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Examples.hs
Examples.hs — haskell source code from the haskell learning materials (haskell/Examples.hs).
記事を読む →
haskell
haskell
更新日 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the haskell learning materials (haskell/Fibonacci.hs).
記事を読む →