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
185185 , filter
186186 , breakOnAll
187187 , find
188+ , elem
188189 , partition
189190
190191 -- , findSubstring
@@ -1503,6 +1504,13 @@ chunksOf k = go
15031504-------------------------------------------------------------------------------
15041505-- ** Searching with a predicate
15051506
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+
15061514-- | /O(n)/ The 'find' function takes a predicate and a 'Text', and
15071515-- returns the first element matching the predicate, or 'Nothing' if
15081516-- 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
191191 -- * Searching
192192 , filter
193193 , find
194+ , elem
194195 , breakOnAll
195196 , partition
196197
@@ -1697,6 +1698,13 @@ find :: (Char -> Bool) -> Text -> Maybe Char
16971698find p t = S. findBy p (stream t)
16981699{-# INLINE find #-}
16991700
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+
17001708-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
17011709-- and returns the pair of 'Text's with elements which do and do not
17021710-- satisfy the predicate, respectively; i.e.
You can’t perform that action at this time.
0 commit comments