ctsTransform :: String -> Int -> String -> Maybe String
ctsTransform _ s dataWord | length dataWord <= s = Nothing
ctsTransform _ _ ('0':ws) = Just ws
ctsTransform codeWord _ ('1':ws) = Just(ws ++ codeWord)
ctsTransform _ _ _ = error "Non-binary data or code given "
cts :: Int -> Int -> [String] -> Int -> String -> [(Int, Int, String)]
cts stepLimit step _ _ _ | step >= stepLimit = []
cts stepLimit step codeWords s dataWord =
case ctsTransform codeWord s dataWord of
Just w -> (step,k,w) : cts stepLimit (step+1) codeWords s w
Nothing -> []
where
k = mod step $ length codeWords
codeWord = codeWords !! k