Z-Data-0.1.2.0: Array, vector and text
Copyright(c) Dong Han 2017-2018
LicenseBSD
Maintainerwinterland1989@gmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Z.Data.Text.Search

Description

 
Synopsis

element-wise search

elem :: Char -> Text -> Bool Source #

O(n) elem test if given char is in given text.

notElem :: Char -> Text -> Bool Source #

O(n) not . elem

Searching by equality

findIndices :: (Char -> Bool) -> Text -> [Int] Source #

find Source #

Arguments

:: (Char -> Bool) 
-> Text 
-> (Int, Int, Maybe Char)

(char index, byte index in slice, matching char)

O(n) find the first char matching the predicate in a text from left to right, if there isn't one, return the index point to the end of the byte slice.

findR Source #

Arguments

:: (Char -> Bool) 
-> Text 
-> (Int, Int, Maybe Char)

(char index(counting backwards), byte index in slice, matching char)

O(n) find the first char matching the predicate in a text from right to left, if there isn't one, return the index point to the start of the byte slice.

findIndex :: (Char -> Bool) -> Text -> Int Source #

O(n) find the index of the byte slice.

findIndexR :: (Char -> Bool) -> Text -> Int Source #

O(n) find the index of the byte slice in reverse order.

filter :: (Char -> Bool) -> Text -> Text Source #

O(n) filter, applied to a predicate and a text, returns a text containing those chars that satisfy the predicate.

partition :: (Char -> Bool) -> Text -> (Text, Text) Source #

O(n) The partition function takes a predicate, a text, returns a pair of text with codepoints which do and do not satisfy the predicate, respectively; i.e.,

partition p txt == (filter p txt, filter (not . p) txt)