on master help sign in
Implement "any" for lists. Obviously this is just the tip of an iceberg.
commit2e994b8939d63f25871d9548ce4a2330db0a87b7 authorIrene Knapp <ireney.knapp@gmail.com> dateMon 23 Jan 2012, 06:57 (15 years ago) parent7c59234
1 file changed+7
lib/prelude/list.idr+7
lib/prelude/list.idr+7
@@ -110,6 +110,13 @@ split p xs = case break p xs of
110110 (chunk, []) => [chunk]
111111 (chunk, (c :: rest)) => chunk :: split p rest
112112
113+any : (a -> Bool) -> List a -> Bool
114+any predicate [] = False
115+any predicate (a::rest) =
116+ if predicate a
117+ then True
118+ else any predicate rest
119+
113120--------------------------------------------------------------------------------
114121-- Conversions
115122--------------------------------------------------------------------------------