Skip to content

Instantly share code, notes, and snippets.

@qoelet
Last active December 24, 2015 20:09
Show Gist options
  • Save qoelet/6855857 to your computer and use it in GitHub Desktop.
Save qoelet/6855857 to your computer and use it in GitHub Desktop.
destruct :: Integer -> [Integer]
destruct 0 = []
destruct x = destruct (x `div` 10) ++ [(x `mod` 10)]
construct :: [Integer] -> Integer
construct [] = 0
construct (x:xs) = (x * (10 ^ (length xs))) + construct xs
-- *Main> construct (destruct 123456)
-- 123456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment