MonadPlus m => (b -> Bool) -> m b -> m b
Direct MonadPlus equivalent of filter filter = (mfilter:: (a -> Bool) -> [a] -> [a] applicable to any MonadPlus, for example mfilter odd (Just 1) == Just 1 mfilter odd (Just 2) == Nothing
O(n). Filter all values that satisfy some predicate.
> filter (> "a") (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
> filter (> "x") (fromList [(5,"a"), (3,"b")]) == empty
> filter (< "a") (fromList [(5,"a"), (3,"b")]) == empty
O(i) p xs</tt> returns the suffix remaining after takeWhileL p xs.
O(n). The filter function takes a predicate p and a sequence xs and returns a sequence of those elements which satisfy the predicate.
O(i) applied to a predicate p and a sequence xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.
O(i) applied to a predicate p and a sequence xs, returns the longest suffix (possibly empty) of xs of elements that satisfy p.
takeWhileR p xs is equivalent to reverse (takeWhileL p (reverse xs)).
O(n). Filter all elements that satisfy the predicate.
dropWhile p xs returns the suffix remaining after takeWhile p xs:
> dropWhile (< 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
> dropWhile (< 9) [1,2,3] == 
> dropWhile (< 0) [1,2,3] == [1,2,3]
filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate; i.e.,
> filter p xs = [ x | x <- xs, p x]
takeWhile, applied to a predicate p and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p:
> takeWhile (< 3) [1,2,3,4,1,2,3,4] == [1,2]
> takeWhile (< 9) [1,2,3] == [1,2,3]
> takeWhile (< 0) [1,2,3] == 
Generates a value that satisfies a predicate.
Conditionally select a BoundedPrim. For example, we can implement the ASCII primitive that drops characters with Unicode codepoints above 127 as follows.
> charASCIIDrop = condB (< '\128') (fromF char7) emptyB
The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.
Execute an IO action, throwing a userError if the predicate yields True when applied to the result returned by the IO action. If no exception is raised, return the result of the computation.
Throw an IOError corresponding to the current value of getErrno if the result value of the IO action meets the given predicate.
as throwErrnoIf, but retry the IO action when it yields the error code eINTR - this amounts to the standard retry loop for interrupted POSIX system calls.
The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.
Can be used to make a string valid for use in a URI.
Show more results