Skip to content

Commit 865ada4

Browse files
committed
WIP: Text: isSubsequenceOf: upd doc (add examples of code & use)
1 parent 2a8e3d9 commit 865ada4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/Data/Text.hs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,11 +1883,25 @@ isInfixOf needle haystack
18831883
| otherwise = not . L.null . indices needle $ haystack
18841884
{-# INLINE [1] isInfixOf #-}
18851885

1886-
-- | The 'isSubsequenceOf' function takes two 'Text's and returns
1887-
-- 'True' iff the second is a subsequence of the first.
1888-
-- (characters of the second argument appear in same sequential order in
1889-
-- the first, to say if second argument can be derived by deleting some
1890-
-- or no elements from the first).
1886+
-- 2021-09-29: NOTE:
1887+
-- * after the implementation - determine & mention the big O
1888+
-- | The 'isSubsequenceOf' function takes the main text and the subsequnce
1889+
-- to find and returns 'True' iff the second argument is a subsequence
1890+
-- of the first.
1891+
--
1892+
-- "Subsequence" used in the meaning of: characters of the second argument
1893+
-- appear in same sequential order in the main data, to say second argument can
1894+
-- be derived by deleting some (any) or no elements from the first.
1895+
--
1896+
-- Examples:
1897+
--
1898+
-- >>> isSubsequenceOf "1234567" "1356"
1899+
-- True
1900+
--
1901+
-- >>> isSubsequenceOf "1234567" "21"
1902+
-- False
1903+
--
1904+
-- `isSubsequenceOf` is the base case & implementation of fuzzy search.
18911905
isSubsequenceOf :: Text -> Text -> Bool
18921906
isSubsequenceOf tf sf
18931907
| length sf > length tf = False

0 commit comments

Comments
 (0)