Mercurial > urweb
diff lib/ur/list.ur @ 822:d4e811beb8eb
fn-pattern code in but not tested yet; hello compiles
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 28 May 2009 10:16:50 -0400 |
parents | 395a5d450cc0 |
children | 78504d97410b |
line wrap: on
line diff
--- a/lib/ur/list.ur Tue May 26 12:25:06 2009 -0400 +++ b/lib/ur/list.ur Thu May 28 10:16:50 2009 -0400 @@ -83,3 +83,29 @@ 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