
Hi, Am Montag, den 13.10.2014, 17:34 +0200 schrieb Niklas Hambüchen:
`isSubsequenceOf` would go into the "Predicates" section (http://hackage.haskell.org/package/base-4.7.0.1/docs/Data-List.html#g:12) which already contains:
* isPrefixOf (dual of inits) * isSuffixOf (dual of tails) * isInfixOf
With this proposal, we would add
* isSubsequenceOf (dual of subsequences)
+1
Suggested implementation:
-- | `isSubsequenceOf a b`: Checks if a is a subsequence of b. isSubsequenceOf :: (Eq a) => [a] -> [a] -> Bool isSubsequenceOf [] _ = True isSubsequenceOf _ [] = False isSubsequenceOf a@(x:a') (y:b) | x == y = isSubsequenceOf a' b | otherwise = isSubsequenceOf a b
The docs should explain what a subsequence is (possibly by giving an educating example, or referring to "subsequences"). Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nomeata@joachim-breitner.de • GPG-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org