From b3633874a48de2fd94bcaa0de2b04ed0d746a6e7 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Wed, 29 Sep 2021 16:42:34 +0300 Subject: [PATCH] WIP: Text: isSubsequenceOf: upd doc (add examples of code & use) --- src/Data/Text.hs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Data/Text.hs b/src/Data/Text.hs index b6b0a645..5802080c 100644 --- a/src/Data/Text.hs +++ b/src/Data/Text.hs @@ -1879,11 +1879,25 @@ isInfixOf needle haystack | otherwise = not . L.null . indices needle $ haystack {-# INLINE [1] isInfixOf #-} --- | The 'isSubsequenceOf' function takes two 'Text's and returns --- 'True' iff the second is a subsequence of the first. --- (characters of the second argument appear in same sequential order in --- the first, to say if second argument can be derived by deleting some --- or no elements from the first). +-- 2021-09-29: NOTE: +-- * after the implementation - determine & mention the big O +-- | The 'isSubsequenceOf' function takes the main text and the subsequnce +-- to find and returns 'True' iff the second argument is a subsequence +-- of the first. +-- +-- "Subsequence" used in the meaning of: characters of the second argument +-- appear in same sequential order in the main data, to say second argument can +-- be derived by deleting some (any) or no elements from the first. +-- +-- Examples: +-- +-- >>> isSubsequenceOf "1234567" "1356" +-- True +-- +-- >>> isSubsequenceOf "1234567" "21" +-- False +-- +-- `isSubsequenceOf` is the base case & implementation of fuzzy search. isSubsequenceOf :: Text -> Text -> Bool isSubsequenceOf tf sf | length sf > length tf = False