10 lines
588 B
Plaintext
10 lines
588 B
Plaintext
-- IMPLIED BASE IMPORT
|
|
isLeaf = (\node : lOr (emptyList node) (emptyList (tail node)))
|
|
getLabel = (\node : head node)
|
|
getLeft = (\node : if (emptyList node) [] (if (emptyList (tail node)) [] (head (tail node))))
|
|
getRight = (\node : if (emptyList node) [] (if (emptyList (tail node)) [] (if (emptyList (tail (tail node))) [] (head (tail (tail node))))))
|
|
|
|
processLevel = y (\self queue : if (emptyList queue) [] (pair (map getLabel queue) (self (filter (\node : not (emptyList node)) (lconcat (map getLeft queue) (map getRight queue))))))
|
|
|
|
levelOrderTraversal = (\a : processLevel (t a t))
|