aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/coll/list.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/coll/list.lux')
-rw-r--r--stdlib/source/lux/data/coll/list.lux30
1 files changed, 30 insertions, 0 deletions
diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux
index 5f41b4381..7f5a71994 100644
--- a/stdlib/source/lux/data/coll/list.lux
+++ b/stdlib/source/lux/data/coll/list.lux
@@ -182,6 +182,36 @@
(#.Some x)
(find p xs'))))
+(def: #export (search check xs)
+ (All [a b]
+ (-> (-> a (Maybe b)) (List a) (Maybe b)))
+ (case xs
+ #.Nil
+ #.None
+
+ (#.Cons [x xs'])
+ (case (check x)
+ (#.Some output)
+ (#.Some output)
+
+ #.None
+ (search check xs'))))
+
+(def: #export (search-all check xs)
+ (All [a b]
+ (-> (-> a (Maybe b)) (List a) (List b)))
+ (case xs
+ #.Nil
+ #.None
+
+ (#.Cons [x xs'])
+ (case (check x)
+ (#.Some output)
+ (#.Cons output (search-all check xs'))
+
+ #.None
+ (search-all check xs'))))
+
(def: #export (interpose sep xs)
{#.doc "Puts a value between every two elements in the list."}
(All [a]