aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/collection/row.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/collection/row.lux')
-rw-r--r--stdlib/source/lux/data/collection/row.lux31
1 files changed, 27 insertions, 4 deletions
diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux
index 7ae37ebea..23e5ded20 100644
--- a/stdlib/source/lux/data/collection/row.lux
+++ b/stdlib/source/lux/data/collection/row.lux
@@ -7,7 +7,8 @@
[equivalence (#+ Equivalence)]
monoid
fold
- ["p" parser]]
+ ["p" parser]
+ [predicate (#+ Predicate)]]
[data
[maybe]
[product]
@@ -15,7 +16,7 @@
[i64]]
[collection
[list ("list/" Fold<List> Functor<List> Monoid<List>)]
- [array ("array/" Functor<Array> Fold<Array>)]]]
+ ["." array ("array/" Functor<Array> Fold<Array>)]]]
[macro (#+ with-gensyms)
[code]
["s" syntax (#+ syntax: Syntax)]]
@@ -434,8 +435,30 @@
(^open) Monoid<Row>]
(fold (function (_ post pre) (compose pre post)) identity))))
-(def: #export (reverse xs)
+(def: #export reverse
(All [a] (-> (Row a) (Row a)))
(let [(^open) Fold<Row>
(^open) Monoid<Row>]
- (fold add identity xs)))
+ (fold add identity)))
+
+(do-template [<name> <array> <init> <op>]
+ [(def: #export <name>
+ (All [a]
+ (-> (Predicate a) (Row a) Bit))
+ (let [help (: (All [a]
+ (-> (Predicate a) (Node a) Bit))
+ (function (help predicate node)
+ (case node
+ (#Base base)
+ (<array> predicate base)
+
+ (#Hierarchy hierarchy)
+ (<array> (help predicate) hierarchy))))]
+ (function (<name> predicate row)
+ (let [(^slots [#root #tail]) row]
+ (<op> (help predicate (#Hierarchy root))
+ (help predicate (#Base tail)))))))]
+
+ [every? array.every? #1 and]
+ [any? array.any? #0 or]
+ )