aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/ur/list.ur14
-rw-r--r--lib/ur/list.urs2
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index 32a9679c..2679d877 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -206,6 +206,20 @@ fun foldlMap [a] [b] [c] f =
fold []
end
+fun find [a] f =
+ let
+ fun find' ls =
+ case ls of
+ [] => None
+ | x :: ls =>
+ if f x then
+ Some x
+ else
+ find' ls
+ in
+ find'
+ end
+
fun search [a] [b] f =
let
fun search' ls =
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index dc8fdeba..00bb5b48 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -44,6 +44,8 @@ val foldlM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type
val foldlMap : a ::: Type -> b ::: Type -> c ::: Type
-> (a -> b -> c * b) -> b -> t a -> t c * b
+val find : a ::: Type -> (a -> bool) -> t a -> option a
+
val search : a ::: Type -> b ::: Type -> (a -> option b) -> t a -> option b
val all : a ::: Type -> (a -> bool) -> t a -> bool