While doing a simple [Exercism 
problem](https://exercism.org/tracks/nim/exercises/sublist), I needed to check 
whether one sequence was a subsequence of another. Having done similar things 
in Haskell, I was hoping there would be similar functions in `sequtils` to 
Haskell's `isPrefixOf` / `isInfixOf` but couldn't find anything. There's a 
`contains` function but of the form `a: Seq[T], b: T`, so that'll only look for 
a single element. But `strutils` has a different `contains(a, b: string)` \-- 
that would seem like what I was missing for sequence types.

Is there something like that in the stdlib that's not specialised to strings? I 
ended up doing it the naieve way by repeatedly comparing one sequence against 
sliding slices of the other sequence, which isn't super efficient compared to 
something like [two-way string 
matching](https://en.wikipedia.org/wiki/Two-way_string-matching_algorithm) or 
<https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm>.

Reply via email to