Sha256: 7f15b6d16864cdbbbe9159e10d7c2d2dc6e1cf627239c55eb87086e6edad1418

Contents?: true

Size: 588 Bytes

Versions: 396

Compression:

Stored size: 588 Bytes

Contents

module Atbash (decode, encode) where

import Data.Char       (isAsciiLower, isDigit, toLower)
import Data.List.Split (chunksOf)
import Data.Maybe      (mapMaybe)

decode :: String -> String
decode = mapMaybe atbashChar

encode :: String -> String
encode = unwords . chunksOf 5 . mapMaybe atbashChar

atbashChar :: Char -> Maybe Char
atbashChar c
    | isDigit c       = Just c
    | isAsciiLower lc = Just symmetric
    | otherwise       = Nothing
  where
    lc = toLower c
    symmetric = toEnum $ fromEnum 'a'
                       + fromEnum 'z'
                       - fromEnum lc

Version data entries

396 entries across 396 versions & 1 rubygems

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