Skip to content

Instantly share code, notes, and snippets.

@cheecheeo
Created May 27, 2014 20:26
Show Gist options
  • Save cheecheeo/283447e42a5482d0ed01 to your computer and use it in GitHub Desktop.
Save cheecheeo/283447e42a5482d0ed01 to your computer and use it in GitHub Desktop.
swap (x,y) = (y,x)
alternate xs ys = Prelude.concat (zipWith (\x y -> [x, y]) xs ys)
-- | Swap then interleave the swapped elements
-- >>> interleaveSwapped [(1,2),(2,3)]
-- [(1,2),(2,1),(2,3),(3,2)]
interleaveSwapped = alternate <*> map swap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment