REPL import warning; version info in CLI
All checks were successful
Test, Build, and Release / test (push) Successful in 1m18s
Test, Build, and Release / build (push) Successful in 1m13s

Adds the ability to toggle result decoding in REPL. Adds several more
useful functions to the base library.
This commit is contained in:
2025-01-30 14:19:30 -06:00
parent bf1000d174
commit 7d1b6a741d
11 changed files with 142 additions and 61 deletions

View File

@ -37,21 +37,21 @@ processLevel = y (\self queue : if (emptyList? queue)
[]
(pair (map label queue) (self (filter
(\node : not? (emptyList? node))
(lconcat (map left queue) (map right queue))))))
(append (map left queue) (map right queue))))))
levelOrderTraversal_ = \a : processLevel (t a t)
toLineString = y (\self levels : if (emptyList? levels)
""
(lconcat
(lconcat (map (\x : lconcat x " ") (head levels)) "")
(if (emptyList? (tail levels)) "" (lconcat (t (t 10 t) t) (self (tail levels))))))
(append
(append (map (\x : append x " ") (head levels)) "")
(if (emptyList? (tail levels)) "" (append (t (t 10 t) t) (self (tail levels))))))
levelOrderToString = \s : toLineString (levelOrderTraversal_ s)
flatten = foldl (\acc x : lconcat acc x) ""
flatten = foldl (\acc x : append acc x) ""
levelOrderTraversal = \s : lconcat (t 10 t) (flatten (levelOrderToString s))
levelOrderTraversal = \s : append (t 10 t) (flatten (levelOrderToString s))
exampleOne = levelOrderTraversal [("1")
[("2") [("4") t t] t]