From 729998f64e891856f43f758551be0aaa26ac89b4 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 24 Jul 2011 15:47:09 -0400 Subject: List.find --- lib/ur/list.ur | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/ur/list.ur') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 32a9679c..2679d877 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -206,6 +206,20 @@ fun foldlMap [a] [b] [c] f = fold [] end +fun find [a] f = + let + fun find' ls = + case ls of + [] => None + | x :: ls => + if f x then + Some x + else + find' ls + in + find' + end + fun search [a] [b] f = let fun search' ls = -- cgit v1.2.3