Created
February 1, 2012 13:02
-
-
Save ldfallas/1716897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Expr = ScSymbol String | |
| ScString String | |
| ScNumber Integer | |
| ScDouble Double | |
| ScCons Expr Expr | |
| ScNil | |
| ScBool Bool | |
| ScQuote Expr | |
deriving Show | |
toString :: Expr -> String | |
toString (ScSymbol name) = name | |
toString (ScNumber num) = show num | |
toString (ScDouble num) = show num | |
toString ScNil = "'()" | |
toString (ScQuote exp) = "'" ++ (toString exp) | |
toString (ScBool value) = if value then "#t" else "#f" | |
toString (ScString str) = "\"" ++ str ++ "\"" | |
toString (ScCons first rest) = "(" ++ (toString first) ++ (toStringCons rest) | |
toStringCons (ScCons part rest) = " " ++ (toString part) ++ toStringCons rest | |
toStringCons ScNil = ")" | |
toStringCons other = "." ++ (toString other) ++ ")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment