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.119 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.118 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.117 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.116 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.115 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.114 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.113 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.111 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.110 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.109 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.108 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.107 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.106 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.105 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.104 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.103 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.102 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.101 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.100 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.99 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs