From 3cb644caeed50e5c82778b5ed7c165950655109a Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 28 May 2009 10:16:50 -0400 Subject: fn-pattern code in but not tested yet; hello compiles --- lib/ur/list.ur | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/ur/list.ur') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 7527362d..90729f5c 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -83,3 +83,29 @@ fun filter (a ::: Type) f = in fil [] end + +fun exists (a ::: Type) f = + let + fun ex ls = + case ls of + [] => False + | x :: ls => + if f x then + True + else + ex ls + in + ex + end + +fun foldlMap (a ::: Type) (b ::: Type) (c ::: Type) f = + let + fun fold ls' st ls = + case ls of + [] => (rev ls', st) + | x :: ls => + case f x st of + (y, st) => fold (y :: ls') st ls + in + fold [] + end -- cgit v1.2.3