Series: Angelia
haskell
10 lines
· Updated 2026-02-03
exercise_4_1 .hs
Angelia/Haskell/Week_6_Lab/exercise_4_1 .hs
-- Function to check if all words start with the same letter
allStartWithSameLetter :: [String] -> Bool
allStartWithSameLetter [] = True -- Empty list returns True
allStartWithSameLetter (x:xs) = myAll (\s -> head s == head x) xs
-- Function to check if any two words start with the same letter
anyStartWithSameLetter :: [String] -> Bool
anyStartWithSameLetter [] = False -- Empty list returns False
anyStartWithSameLetter [_] = False -- Single-element list returns False
anyStartWithSameLetter (x:xs) = myAny (\s -> head s == head x) xs || anyStartWithSameLetter xs
Related articles
Angelia
haskell
Updated 2026-02-03
Adding.hs
Adding.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Adding.hs).
Read article →
Angelia
haskell
Updated 2026-02-03
Area.hs
Area.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Area.hs).
Read article →
Angelia
haskell
Updated 2026-02-03
Chess.hs
Chess.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Chess.hs).
Read article →
Angelia
haskell
Updated 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/ChessGraphics.hs).
Read article →
Angelia
haskell
Updated 2026-02-03
Examples.hs
Examples.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Examples.hs).
Read article →
Angelia
haskell
Updated 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the Angelia learning materials (Angelia/Haskell/Fibonacci.hs).
Read article →