Mercurial > urweb
comparison lib/ur/list.ur @ 1519:ada582d07ae1
List.find
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 24 Jul 2011 15:47:09 -0400 |
parents | 3061d1bf4b2d |
children | dde3bd82cb3d |
comparison
equal
deleted
inserted
replaced
1518:883347f5c3c2 | 1519:ada582d07ae1 |
---|---|
204 (y, st) => fold (y :: ls') st ls | 204 (y, st) => fold (y :: ls') st ls |
205 in | 205 in |
206 fold [] | 206 fold [] |
207 end | 207 end |
208 | 208 |
209 fun find [a] f = | |
210 let | |
211 fun find' ls = | |
212 case ls of | |
213 [] => None | |
214 | x :: ls => | |
215 if f x then | |
216 Some x | |
217 else | |
218 find' ls | |
219 in | |
220 find' | |
221 end | |
222 | |
209 fun search [a] [b] f = | 223 fun search [a] [b] f = |
210 let | 224 let |
211 fun search' ls = | 225 fun search' ls = |
212 case ls of | 226 case ls of |
213 [] => None | 227 [] => None |