Sha256: f2e4da29d9fc568ec32c021c9506011b47591174d51adb72e5738ed8b73ecba8

Contents?: true

Size: 524 Bytes

Versions: 396

Compression:

Stored size: 524 Bytes

Contents

module Hexadecimal (hexToInt) where

{-# ANN digitToInt "HLint: ignore Use isDigit" #-}
digitToInt :: Char -> Maybe Int
digitToInt c
  | c >= '0' && c <= '9' = Just $ n - fromEnum '0'
  | c >= 'a' && c <= 'f' = Just $ n - fromEnum 'a' + 10
  | c >= 'A' && c <= 'F' = Just $ n - fromEnum 'A' + 10
  | otherwise            = Nothing
  where n = fromEnum c

hexToInt :: String -> Int
hexToInt = go 0
  where
    go acc (c:cs) = case digitToInt c of
      Just n -> (go $! acc * 16 + n) cs
      _      -> 0
    go acc [] = acc

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.179 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.178 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.177 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.176 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.175 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.174 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.173 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.172 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.171 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.170 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.169 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.167 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.166 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.165 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.164 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.163 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.162 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.161 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.160 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs