Chaocipher: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Tidied one function in applicative terms.) |
|||
Line 858: | Line 858: | ||
rotated :: Int -> [a] -> [a] |
rotated :: Int -> [a] -> [a] |
||
rotated n = take |
rotated n = take . length <*> drop n . cycle |
||
shifted :: Int -> Int -> [a] -> [a] |
shifted :: Int -> Int -> [a] -> [a] |
||
shifted src dst s = concat [x, rotated 1 y, b] |
shifted src dst s = concat [x, rotated 1 y, b] |
||
where |
where |
||
(a, b) = splitAt dst s |
(a, b) = splitAt dst s |
||
(x, y) = splitAt src a |
(x, y) = splitAt src a |
||
encode = False |
encode = False |