Skip to content

Instantly share code, notes, and snippets.

@auduchinok
Created January 22, 2015 11:07
Show Gist options
  • Save auduchinok/4d48c88a24fd401c5eb2 to your computer and use it in GitHub Desktop.
Save auduchinok/4d48c88a24fd401c5eb2 to your computer and use it in GitHub Desktop.
Haskell Exam
revert :: L a -> L a
revert N = N
revert (O a x b) = O (revert b) x (revert a)
revert (E a b) = E (revert b) (revert a)
instance (Show a) => Show (L a) where
show N = "[]"
show x = "[" ++ (init $ show' x) ++ "]" where
show' N = ""
show' (E a b) = show' a ++ show' b
show' (O a x b) = show' a ++ show x ++ "," ++ show' b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment