Initial ternary representation options

Both parsing and conversion from T to ternary representation supported
This commit is contained in:
2024-12-30 08:30:40 -06:00
committed by James Eversole
parent 9bc0410846
commit 78dd2f4d8f
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