Substitution cipher: Difference between revisions
Content added Content deleted
Line 882: | Line 882: | ||
shuffle 0 xs = xs |
shuffle 0 xs = xs |
||
shuffle n xs = iterate go xs !! n |
shuffle n xs = iterate go xs !! n |
||
where |
where |
||
go [] = [] |
|||
go xs = go (drop 2 xs) <> take 2 xs |
|||
convert :: [(Char, Char)] -> String -> String |
convert :: [(Char, Char)] -> String -> String |
||
Line 889: | Line 890: | ||
convert m (x:xs) = case lookup x m of |
convert m (x:xs) = case lookup x m of |
||
Just c -> c : convert m xs |
Just c -> c : convert m xs |
||
Nothing -> |
Nothing -> x : convert m xs |
||
runCommand :: Command -> String |
runCommand :: Command -> String |