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

Version Path
trackler-2.2.1.117 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.116 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.115 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.114 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.113 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.111 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.110 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.109 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.108 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.107 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.106 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.105 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.104 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.103 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.102 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.101 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.100 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.99 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.98 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs
trackler-2.2.1.97 tracks/haskell/exercises/largest-series-product/examples/success-standard/src/Series.hs