Initial ternary representation options

Both parsing and conversion from T to ternary representation supported
This commit is contained in:
James Eversole
2024-12-30 08:30:40 -06:00
parent fe70aa72ac
commit 8622af9ad2
4 changed files with 45 additions and 3 deletions

View File

@ -88,6 +88,12 @@ toList (Fork x rest) = case toList rest of
Left err -> Left err
toList _ = Left "Invalid Tree Calculus list"
-- Outputs
toTernaryString :: T -> String
toTernaryString Leaf = "0"
toTernaryString (Stem t) = "1" ++ toTernaryString t
toTernaryString (Fork t1 t2) = "2" ++ toTernaryString t1 ++ toTernaryString t2
-- Utility
type Env = Map.Map String T