Skip to content

Instantly share code, notes, and snippets.

@loosechainsaw
Last active August 29, 2015 14:01
Show Gist options
  • Save loosechainsaw/70d236fad9b14c9c26e4 to your computer and use it in GitHub Desktop.
Save loosechainsaw/70d236fad9b14c9c26e4 to your computer and use it in GitHub Desktop.
appendSwapped.hs
module Main where
appendSwapped :: [(a,a)] -> [(a,a)]
appendSwapped [] = []
appendSwapped xs = xs ++ (flipped xs)
where flipped li = foldr (\c d -> swaptuple c : d ) [] li
swaptuple (a,b) = (b,a)
main :: IO ()
main = print $ appendSwapped [(1,2), (3,4)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment