File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ module Data.Text
185
185
, filter
186
186
, breakOnAll
187
187
, find
188
+ , elem
188
189
, partition
189
190
190
191
-- , findSubstring
@@ -1503,6 +1504,13 @@ chunksOf k = go
1503
1504
-------------------------------------------------------------------------------
1504
1505
-- ** Searching with a predicate
1505
1506
1507
+ -- | /O(n)/ The 'elem' function takes a character and a 'Text', and
1508
+ -- returns 'True' if the element is found in the given 'Text', or
1509
+ -- 'False' otherwise.
1510
+ elem :: Char -> Text -> Bool
1511
+ elem c t = S. any (== c) (stream t)
1512
+ {-# INLINE elem #-}
1513
+
1506
1514
-- | /O(n)/ The 'find' function takes a predicate and a 'Text', and
1507
1515
-- returns the first element matching the predicate, or 'Nothing' if
1508
1516
-- there is no such element. Subject to fusion.
Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ module Data.Text.Lazy
191
191
-- * Searching
192
192
, filter
193
193
, find
194
+ , elem
194
195
, breakOnAll
195
196
, partition
196
197
@@ -1697,6 +1698,13 @@ find :: (Char -> Bool) -> Text -> Maybe Char
1697
1698
find p t = S. findBy p (stream t)
1698
1699
{-# INLINE find #-}
1699
1700
1701
+ -- | /O(n)/ The 'elem' function takes a character and a 'Text', and
1702
+ -- returns 'True' if the element is found in the given 'Text', or
1703
+ -- 'False' otherwise.
1704
+ elem :: Char -> Text -> Bool
1705
+ elem c t = S. any (== c) (stream t)
1706
+ {-# INLINE elem #-}
1707
+
1700
1708
-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
1701
1709
-- and returns the pair of 'Text's with elements which do and do not
1702
1710
-- satisfy the predicate, respectively; i.e.
You can’t perform that action at this time.
0 commit comments