aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2017-06-23 19:48:36 -0400
committerEduardo Julian2017-06-23 19:48:36 -0400
commitbed22d326d1a7555dbcfd589da51a592bfa9113b (patch)
treed597299e84a97ce3e0af93150b58744bf122c94e /stdlib/source
parent024d9990d005971e5c9a238bda8de620cd3b2fc1 (diff)
- Added Fold structure for rose trees.
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/data/coll/tree/rose.lux12
1 files changed, 10 insertions, 2 deletions
diff --git a/stdlib/source/lux/data/coll/tree/rose.lux b/stdlib/source/lux/data/coll/tree/rose.lux
index 5493d6692..b4ac0c313 100644
--- a/stdlib/source/lux/data/coll/tree/rose.lux
+++ b/stdlib/source/lux/data/coll/tree/rose.lux
@@ -3,8 +3,9 @@
(lux (control functor
monad
eq
- ["p" parser])
- (data (coll [list "L/" Monad<List>]))
+ ["p" parser]
+ fold)
+ (data (coll [list "L/" Monad<List> Fold<List>]))
[macro]
(macro [code]
["s" syntax #+ syntax: Syntax])))
@@ -63,3 +64,10 @@
{#value (f (get@ #value fa))
#children (L/map (map f)
(get@ #children fa))}))
+
+(struct: #export _ (Fold Tree)
+ (def: (fold f init tree)
+ (L/fold (function [tree' init'] (fold f init' tree'))
+ (f (get@ #value tree)
+ init)
+ (get@ #children tree))))