Last active
July 31, 2023 11:09
-
-
Save drchaos/c4f8b4390794355402fd03db68976fd9 to your computer and use it in GitHub Desktop.
Boyer-Moore matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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