Allow lambda expressions without explicit paren
All checks were successful
Test, Build, and Release / test (push) Successful in 1m41s
Test, Build, and Release / build (push) Successful in 1m19s

This commit is contained in:
James Eversole
2025-01-26 08:52:28 -06:00
parent ea128929da
commit e2621bc09d
9 changed files with 63 additions and 87 deletions

View File

@ -6,7 +6,7 @@ demo_true = t t
not_TC? = t (t (t t) (t t t)) (t t (t t t))
-- /demos/toSource.tri contains an explanation of `triage`
demo_triage = (\a b c : t (t a b) c)
demo_triage = \a b c : t (t a b) c
demo_matchBool = (\ot of : demo_triage
of
(\_ : ot)

View File

@ -17,9 +17,9 @@
-- 4 5 6
--
label = (\node : head node)
label = \node : head node
left = (\node : if (emptyList? node)
left = (\node : if (emptyList? node)
[]
(if (emptyList? (tail node))
[]
@ -39,7 +39,7 @@ processLevel = y (\self queue : if (emptyList? queue)
(\node : not? (emptyList? node))
(lconcat (map left queue) (map right queue))))))
levelOrderTraversal_ = (\a : processLevel (t a t))
levelOrderTraversal_ = \a : processLevel (t a t)
toLineString = y (\self levels : if (emptyList? levels)
""
@ -47,11 +47,11 @@ toLineString = y (\self levels : if (emptyList? levels)
(lconcat (map (\x : lconcat x " ") (head levels)) "")
(if (emptyList? (tail levels)) "" (lconcat (t (t 10 t) t) (self (tail levels))))))
levelOrderToString = (\s : toLineString (levelOrderTraversal_ s))
levelOrderToString = \s : toLineString (levelOrderTraversal_ s)
flatten = foldl (\acc x : lconcat acc x) ""
levelOrderTraversal = (\s : lconcat (t 10 t) (flatten (levelOrderToString s)))
levelOrderTraversal = \s : lconcat (t 10 t) (flatten (levelOrderToString s))
exampleOne = levelOrderTraversal [("1")
[("2") [("4") t t] t]

View File

@ -1,4 +1,4 @@
compose = (\f g x : f (g x))
compose = \f g x : f (g x)
succ = y (\self :
triage

View File

@ -40,7 +40,7 @@ toSource_ = y (\self arg :
arg) -- The term to be inspected
-- toSource takes a single TC term and returns a String
toSource = (\v : toSource_ v "")
toSource = \v : toSource_ v ""
exampleOne = toSource true -- OUT: "(t t)"
exampleTwo = toSource not? -- OUT: "(t (t (t t) (t t t)) (t t (t t t)))"