changeset 2095:d9f918b79b5a

List.mem
author Adam Chlipala <adam@chlipala.net>
date Tue, 23 Dec 2014 14:41:23 -0500
parents 0d898b086bbe
children 6b7749da1ddc
files lib/ur/list.ur lib/ur/list.urs
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/list.ur	Tue Dec 23 13:42:20 2014 -0500
+++ b/lib/ur/list.ur	Tue Dec 23 14:41:23 2014 -0500
@@ -216,6 +216,16 @@
         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 =
--- a/lib/ur/list.urs	Tue Dec 23 13:42:20 2014 -0500
+++ b/lib/ur/list.urs	Tue Dec 23 14:41:23 2014 -0500
@@ -54,6 +54,8 @@
 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