[Jprogramming] lazily look for label?

Marshall Lochbaum mwlochbaum at gmail.com
Thu Oct 13 01:49:17 HKT 2011


J's E. implements Boyer-Moore, which makes it much faster than a standard
search. You could implement a standard search using sequential machines
(well, if you don't mind a transition table that grows with the size of the
label to find), but I'm fairly sure it's impossible to implement Boyer-Moore
using sequential machines, so your search would be several times slower and
probably not worth the advantage you get from stopping early.

Marshall

On Wed, Oct 12, 2011 at 1:41 PM, Alan Stebbens <aks at stebbens.org> wrote:

> It seems to me that another possibility for iterative and lazy evaluation
> is the finite sequential machine (;:), with a cleverly designed state table,
> such that a "stop" (code 6) or an "error" (_1) is thrown and then caught by
> logic in the state table, so that parsing all the input is not always
> required.
>
> Alan
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


More information about the Programming mailing list