aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/collection/tree.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/data/collection/tree.lux16
1 files changed, 9 insertions, 7 deletions
diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux
index 7a14946c5..23a957fb7 100644
--- a/stdlib/source/library/lux/data/collection/tree.lux
+++ b/stdlib/source/library/lux/data/collection/tree.lux
@@ -17,14 +17,16 @@
["." code]]]])
(type: #export (Tree a)
+ {#.doc (doc "A generic tree data-structure.")}
{#value a
#children (List (Tree a))})
-(def: #export (flatten tree)
+(def: #export (flat tree)
+ {#.doc (doc "All the leaf values of the tree, in order.")}
(All [a] (-> (Tree a) (List a)))
(|> tree
(get@ #children)
- (list\map flatten)
+ (list\map flat)
list\join
(#.Item (get@ #value tree))))
@@ -49,16 +51,16 @@
<>.rec
<>.some
<code>.record
- (<>.default (list))
+ (<>.else (list))
(<>.and <code>.any)))
(syntax: #export (tree {root tree^})
{#.doc (doc "Tree literals."
(: (Tree Nat)
- (tree 10
- {20 {}
- 30 {}
- 40 {}})))}
+ (tree 12
+ {34 {}
+ 56 {}
+ 78 {90 {}}})))}
(in (list (` (~ (loop [[value children] root]
(` {#value (~ value)
#children (list (~+ (list\map recur children)))})))))))