aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-28 10:16:50 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-28 10:16:50 -0400
commit3cb644caeed50e5c82778b5ed7c165950655109a (patch)
tree2173bd760a25b12356629888a84ae960f9c1dd80 /lib/ur/list.ur
parentd8801e05ef2f81f21eb27555b626ee2e52c3365f (diff)
fn-pattern code in but not tested yet; hello compiles
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur26
1 files changed, 26 insertions, 0 deletions
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