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.98 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.97 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.96 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.95 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.94 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.93 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.92 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.91 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.90 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.89 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.88 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.87 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.86 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.85 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.84 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.83 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.82 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.81 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.80 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs
trackler-2.2.1.79 tracks/haskell/exercises/hexadecimal/examples/success-standard/src/Hexadecimal.hs