Skip to content

Instantly share code, notes, and snippets.

@craigjbass
Last active December 26, 2015 13:59
Show Gist options
  • Select an option

  • Save craigjbass/7161671 to your computer and use it in GitHub Desktop.

Select an option

Save craigjbass/7161671 to your computer and use it in GitHub Desktop.
splicer :: [[a]] -> [[a]] such that the following holds true: splicer [ ['a', 'b'], ['c', 'd'], ['e', 'f'] ] => [ ['a', 'c', 'e'], ['b', 'd', 'f'] ] Useful for use in Vigenere cipher breakers.
-- such that the following holds true (where => indicates function output)
-- splicer [ ['a', 'b'], ['c', 'd'], ['e', 'f'] ] => [ ['a', 'c', 'e'], ['b', 'd', 'f'] ]
splicer :: [[a]] -> [[a]]
splicer [] = []
splicer (x:[]) = splitEvery 1 x
splicer (x:xs) = zipWith (:) x $ splicer xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment