Chaocipher: Difference between revisions

m
→‎{{header|Haskell}}: Tidied one function in applicative terms.
m (fix end HTML tab.)
m (→‎{{header|Haskell}}: Tidied one function in applicative terms.)
Line 840:
<lang haskell>import Data.List (elemIndex)
 
chao
chao :: Eq a => [a] -> [a] -> Bool -> [a] -> [a]
:: Eq a
chao :: Eq a => [a] -> [a] -> Bool -> [a] -> [a]
chao _ _ _ [] = []
chao l r plain (x:xs) = maybe [] go (elemIndex x src)
Line 856 ⟶ 858:
 
rotated :: Int -> [a] -> [a]
rotated z sn = take (<$> length s)<*> (drop zn . (cycle s))
 
shifted :: Int -> Int -> [a] -> [a]
shifted src dst s = concat [x, rotated 1 y, b]
where
let (a, b) = splitAt dst s
(xa, yb) = splitAt srcdst as
in concat [(x, rotatedy) 1= y,splitAt src b]a
 
 
encode = False
9,655

edits