diff options
author | Eduardo Julian | 2017-06-23 19:48:36 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-06-23 19:48:36 -0400 |
commit | bed22d326d1a7555dbcfd589da51a592bfa9113b (patch) | |
tree | d597299e84a97ce3e0af93150b58744bf122c94e /stdlib/source | |
parent | 024d9990d005971e5c9a238bda8de620cd3b2fc1 (diff) |
- Added Fold structure for rose trees.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/coll/tree/rose.lux | 12 |
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)))) |