Ad
Algorithms
Logic

Using all to communicate semantics

Code
Diff
  • module AllEqual where
    
    allEqual :: [Int] -> Bool
    allEqual []     = True
    allEqual (x:xs) = all (== x) xs
    • module AllEqual where
    • import Data.Foldable(foldl')
    • allEqual :: [Int] -> Bool
    • allEqual [] = True
    • allEqual (x:xs) = foldl' (\b a -> b && (a==x)) True xs
    • allEqual (x:xs) = all (== x) xs