Skip to content

Instantly share code, notes, and snippets.

@drchaos
Last active July 31, 2023 11:09
Show Gist options
  • Save drchaos/c4f8b4390794355402fd03db68976fd9 to your computer and use it in GitHub Desktop.
Save drchaos/c4f8b4390794355402fd03db68976fd9 to your computer and use it in GitHub Desktop.
Boyer-Moore matcher
matchUp :: ByteString
-> ByteString
-> Bool
matchUp pat
| null pat = null
matchUp pat = searcher
where
searcher = case nonOverlappingIndicies pat of -- это библиотечная функция
[] -> False
_ -> True
-- Вычисление таблички произойдет при первом вызове
let check = matchUp "pat"
in any [check "foobarbaz", check "foopatbarbaz" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment