diff options
author | Camil Staps | 2016-02-12 15:01:00 +0100 |
---|---|---|
committer | Camil Staps | 2016-02-12 15:01:00 +0100 |
commit | efd533331d6a7f0c51ef857af448a6c84c3084ed (patch) | |
tree | 7f28f4e20a215784f27643ad49029332204528b2 /Assignment1/CamilStaps-assignment1-shift.hs | |
parent | Makefile (diff) |
Removed spaces in path
Diffstat (limited to 'Assignment1/CamilStaps-assignment1-shift.hs')
-rw-r--r-- | Assignment1/CamilStaps-assignment1-shift.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Assignment1/CamilStaps-assignment1-shift.hs b/Assignment1/CamilStaps-assignment1-shift.hs new file mode 100644 index 0000000..35a34e7 --- /dev/null +++ b/Assignment1/CamilStaps-assignment1-shift.hs @@ -0,0 +1,14 @@ +import System.Environment +import Data.String.Utils + +main = do + args <- getArgs + let input = replace " " "" (head args) + print $ map (`shiftN` (read $ args!!1)) input + +-- shiftN c i: shift c i times forward (i.e. shiftN 'A' 1 == 'B') +-- Only for uppercase letters +shiftN :: Char -> Int -> Char +shiftN c 0 = c +shiftN 'Z' i = shiftN 'A' (i-1) +shiftN c i = shiftN (toEnum ((fromEnum c) + 1)) (i-1)
\ No newline at end of file |