Skip to content

Commit b363387

Browse files
committed
WIP: Text: isSubsequenceOf: upd doc (add examples of code & use)
1 parent f14d7cb commit b363387

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
@@ -1879,11 +1879,25 @@ isInfixOf needle haystack
18791879
| otherwise = not . L.null . indices needle $ haystack
18801880
{-# INLINE [1] isInfixOf #-}
18811881

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

0 commit comments

Comments
 (0)