S-expressions: Difference between revisions

Content added Content deleted
(→‎{{header|Haskell}}: Additional output, expression serialized from parse tree.)
Line 3,133: Line 3,133:
treeFromVal v = Node v []
treeFromVal v = Node v []


------------------------ FORMATTING ----------------------
----------------------- SERIALIZING ----------------------

ppExpr trees = unwords (go <$> trees)
where
go (Node v xs) = "OK"


litVal (Symbol x) = x
litVal (Symbol x) = x
Line 3,144: Line 3,140:
litVal (String x) = '"' : x <> "\""
litVal (String x) = '"' : x <> "\""
litVal (List [List xs]) = litVal (List xs)
litVal (List [List xs]) = litVal (List xs)
litVal (List xs) = "(" <> unwords (litVal <$> xs) <> ")"
litVal (List xs) = '(' : (unwords (litVal <$> xs) <> ")")


------------------------- GENERIC ------------------------
------------------------- GENERIC ------------------------