Hello,
I think this function might be of help in Data.List. Why I believe it
would be good to have it in base: `elem` is accompanied by `findIndex`
but `isInfixOf` doesn't have an accompanist.
Cheers,
Carlos
-- | Receives a sublist and a list. It returns the index where the
sublist appears in the list. For example:
--
-- > findSublistIndex "abc" "abcabbc" == Just 0
-- > findSublistIndex findSublistIndex [5,6] [1..] == Just 4
-- > findSublistIndex "abbc" "abcabbc" == Just 3
-- > findSublistIndex [2,1] [2,4..10] == Nothing
findSublistIndex :: (Eq a) => [a] -> [a] -> Maybe Int
findSublistIndex [] _ = Nothing
findSublistIndex sublist list = findSeqIndex sublist list 0 where
findSeqIndex _ [] _ = Nothing
findSeqIndex sublist' list'@(x:xs) i = if (sublist' `isPrefixOf`
list') then Just i else findSeqIndex sublist' xs (i+1)