on master help sign in
Implement "any" for lists. Obviously this is just the tip of an iceberg.
2e994b8Irene Knapp
lib/prelude/list.idr+7
@@ -110,6 +110,13 @@ split p xs = case break p xs of
110 (chunk, []) => [chunk]
110 (chunk, []) => [chunk]
111 (chunk, (c :: rest)) => chunk :: split p rest
111 (chunk, (c :: rest)) => chunk :: split p rest
112
112
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+
113--------------------------------------------------------------------------------
120--------------------------------------------------------------------------------
114-- Conversions
121-- Conversions
115--------------------------------------------------------------------------------
122--------------------------------------------------------------------------------