Sha256: 8986a3bfdb06865da8f48cecd7ef08570be66a613a7f26a6cadcf2a983b74989
Contents?: true
Size: 311 Bytes
Versions: 396
Compression:
Stored size: 311 Bytes
Contents
{-# LANGUAGE BangPatterns #-} module Binary (toDecimal) where import Control.Monad (foldM) import Data.Maybe (fromMaybe) toDecimal :: String -> Int toDecimal = fromMaybe 0 . foldM go 0 where go !n c = (n * 2 +) `fmap` toDigit c toDigit '0' = Just 0 toDigit '1' = Just 1 toDigit _ = Nothing
Version data entries
396 entries across 396 versions & 1 rubygems