Proposal: Add isSubsequenceOf to Data.List

Herbert Valerio Riedel hvr at gnu.org
Tue Oct 14 16:00:19 UTC 2014


On 2014-10-13 at 17:34:17 +0200, Niklas Hambüchen wrote:

[...]

> With this proposal, we would add
>
> * isSubsequenceOf (dual of subsequences)
>
>
> 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

+1


More information about the Libraries mailing list