takeWhile package:rio
takeWhile, applied to a predicate
p and a ByteString
xs, returns the longest prefix (possibly empty) of
xs of elements that satisfy
p.
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] == []
takeWhile p xs returns the longest prefix of the
stream
xs for which the predicate
p holds.
O(n) takeWhile, applied to a predicate
p and a
Text, returns the longest prefix (possibly empty) of elements
that satisfy
p. Subject to fusion.
O(n) Yield the longest prefix of elements satisfying the
predicate. Current implementation is not copy-free, unless the result
vector is fused away.
O(n) Yield the longest prefix of elements satisfying the
predicate. Current implementation is not copy-free, unless the result
vector is fused away.
O(n) Yield the longest prefix of elements satisfying the
predicate. Current implementation is not copy-free, unless the result
vector is fused away.
O(n) Yield the longest prefix of elements satisfying the
predicate. Current implementation is not copy-free, unless the result
vector is fused away.
O(log n). Take while a predicate on the keys holds. The user is
responsible for ensuring that for all keys
j and
k
in the map,
j < k ==> p j >= p k. See note at
spanAntitone.
takeWhileAntitone p = fromDistinctAscList . takeWhile (p . fst) . toList
takeWhileAntitone p = filterWithKey (k _ -> p k)
where <math> is the prefix length.
takeWhileL, applied to a predicate
p and a sequence
xs, returns the longest prefix (possibly empty) of
xs of elements that satisfy
p.
where <math> is the suffix length.
takeWhileR, 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(log n). Take while a predicate on the elements holds. The
user is responsible for ensuring that for all elements
j and
k in the set,
j < k ==> p j >= p k. See
note at
spanAntitone.
takeWhileAntitone p = fromDistinctAscList . takeWhile p . toList
takeWhileAntitone p = filter p
O(n) takeWhileEnd, applied to a predicate
p and
a
Text, returns the longest suffix (possibly empty) of elements
that satisfy
p. Subject to fusion. Examples:
>>> takeWhileEnd (=='o') "foo"
"oo"
O(n) takeWhileEnd, applied to a predicate
p and
a
Text, returns the longest suffix (possibly empty) of elements
that satisfy
p. Examples:
takeWhileEnd (=='o') "foo" == "oo"