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.159 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.158 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.157 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.156 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.155 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.154 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.153 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.152 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.151 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.150 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.149 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.148 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.147 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.146 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.145 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.144 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.143 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.142 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.141 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.140 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs