Definition dependency analysis
tricu now allows defining terms in any order and will resolve dependencies to ensure that they're evaluated in the right order. Undefined terms are detected and throw errors during dependency ordering. For now we can't define top-level mutually recursive terms.
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
-- Level Order Traversal of a labelled binary tree
|
||||
-- Objective: Print each "level" of the tree on a separate line
|
||||
--
|
||||
-- NOTICE: This demo relies on tricu base library functions
|
||||
--
|
||||
-- We model labelled binary trees as sublists where values act as labels. We
|
||||
-- require explicit not?ation of empty nodes. Empty nodes can be represented
|
||||
-- with an empty list, `[]`, which is equivalent to a single node `t`.
|
||||
-- We model labelled binary trees as nested lists where values act as labels. We
|
||||
-- require explicit notation of empty nodes. Empty nodes can be represented
|
||||
-- with an empty list, `[]`, which evaluates to a single node `t`.
|
||||
--
|
||||
-- Example tree inputs:
|
||||
-- [("1") [("2") [("4") t t] t] [("3") [("5") t t] [("6") t t]]]]
|
||||
@ -15,7 +13,6 @@
|
||||
-- 2 3
|
||||
-- / / \
|
||||
-- 4 5 6
|
||||
--
|
||||
|
||||
label = \node : head node
|
||||
|
||||
|
@ -1,21 +1,21 @@
|
||||
compose = \f g x : f (g x)
|
||||
|
||||
succ = y (\self :
|
||||
triage
|
||||
1
|
||||
t
|
||||
(triage
|
||||
(t (t t))
|
||||
(\_ tail : t t (self tail))
|
||||
succ = y (\self :
|
||||
triage
|
||||
1
|
||||
t
|
||||
(triage
|
||||
(t (t t))
|
||||
(\_ tail : t t (self tail))
|
||||
t))
|
||||
|
||||
size = (\x :
|
||||
(y (\self x :
|
||||
compose succ
|
||||
(triage
|
||||
(\x : x)
|
||||
self
|
||||
(\x y : compose (self x) (self y))
|
||||
size = (\x :
|
||||
(y (\self x :
|
||||
compose succ
|
||||
(triage
|
||||
(\x : x)
|
||||
self
|
||||
(\x y : compose (self x) (self y))
|
||||
x)) x 0))
|
||||
|
||||
size size
|
||||
|
Reference in New Issue
Block a user