diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-05-28 10:16:50 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-05-28 10:16:50 -0400 |
commit | 072ba13540fd884e01c8d2aab31853594825e000 (patch) | |
tree | 2173bd760a25b12356629888a84ae960f9c1dd80 /lib/ur/list.ur | |
parent | d4748e41f7fc4865db89ebac0c7f646dca82f89a (diff) |
fn-pattern code in but not tested yet; hello compiles
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r-- | lib/ur/list.ur | 26 |
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 |