Sha256: c381449a2534a89c77cbcb46eb835eeffe5df715edf475d13b59249a6ce9bc26
Contents?: true
Size: 587 Bytes
Versions: 334
Compression:
Stored size: 587 Bytes
Contents
module Series (largestProduct) where import Control.Monad ((>=>)) import Data.Char (digitToInt, isDigit) import Data.List (tails) import Data.Maybe (mapMaybe) import Safe (maximumMay) import Safe.Exact (takeExactMay) largestProduct :: (Integral a, Num b, Ord b) => a -> String -> Maybe b largestProduct n = traverse charToNum >=> maximumMay . products where products = mapMaybe (fmap product . takeExactMay (fromIntegral n)) . tails charToNum x | isDigit x = Just . fromIntegral . digitToInt $ x | otherwise = Nothing
Version data entries
334 entries across 334 versions & 1 rubygems