ocaml-batteries-team/batteries-included — pull request #377 by madroach (2013-05-28 12:51:25+00:00)
Title: add improved horspool text searching algorithm

This may not be perfect yet and is presented for discussion.

I'm not sure whether I'm doing the right thing concerning rfind_from.
First of all the current documentation is wrong. rfind_from starts to search backwards from exactly the given position, not pos+1.
But I think starting the search from _right before_ the given position is more natural in the big picture.
Now the following is true:
```
rfind_adaptive pattern text pos
=
rfind (sub text 0 pos) pattern

rfind text pattern = rfind_adaptive pattern text (length text)
```

I also changed the call semantics from [find* text pos pattern] to [find* pattern text pos] to allow early initialization on partial binding.
I'm not sure whether this hurts more than it helps, especially that we now have a lazy find_all.