summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-12-23 14:41:23 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2014-12-23 14:41:23 -0500
commit02a7a466cb332b0d90cf0ec17c6ad9ae7a78ec49 (patch)
treefaf593f9e7282d65f7d1740cc0188c4f3c2fde6c /lib
parentddb9bc67c740c21040267f2a6a68fd72f2cdfa25 (diff)
List.mem
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/list.ur10
-rw-r--r--lib/ur/list.urs2
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index cbb4faf2..11895884 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -216,6 +216,16 @@ fun foldlMap [a] [b] [c] f =
fold []
end
+fun mem [a] (_ : eq a) (x : a) =
+ let
+ fun mm ls =
+ case ls of
+ [] => False
+ | y :: ls => y = x || mm ls
+ in
+ mm
+ end
+
fun find [a] f =
let
fun find' ls =
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index 66007a39..55068935 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -54,6 +54,8 @@ val filterM : m ::: (Type -> Type) -> monad m -> a ::: Type
val foldlMap : a ::: Type -> b ::: Type -> c ::: Type
-> (a -> b -> c * b) -> b -> t a -> t c * b
+val mem : a ::: Type -> eq a -> a -> t a -> bool
+
val find : a ::: Type -> (a -> bool) -> t a -> option a
val search : a ::: Type -> b ::: Type -> (a -> option b) -> t a -> option b