Eban numbers: Difference between revisions

Content added Content deleted
Line 657: Line 657:
{{trans|Julia}}
{{trans|Julia}}
<lang haskell>{-# LANGUAGE NumericUnderscores #-}
<lang haskell>{-# LANGUAGE NumericUnderscores #-}

anyPass :: [a -> Bool] -> a -> Bool
anyPass [] _ = False
anyPass (f:fs) x = f x || anyPass fs x


isEban :: Int -> Bool
isEban :: Int -> Bool
isEban n = all (anyPass [(==0), (==2), (==4), (==6)]) z
isEban n = all (`elem` [0, 2, 4, 6]) z
where
where
(b, r1) = n `quotRem` (10 ^ 9)
(b, r1) = n `quotRem` (10 ^ 9)