Optimizing pattern matching
GavinWraith (26) 1563 posts |
Optimizing pattern matching – a nicely illustrated little blog by Julien Desgats , with animations of transformations on Abstract Syntax Trees. Though this has little to do with RISC OS (apart from the fact that RiscLua has Lpeg) it may appeal to forum readers interested in a problem of pure computer science . Suppose you are searching text for the words bar , foo , or baz , in that order of priority. The corresponding Lpeg pattern is It would be more efficient to re-express this as
In other words, to minimize reduplication of effort, extract common subpatterns. For large patterns, with hundreds of alternatives, the gains in efficiency can be dramatic.
|
h0bby1 (2567) 480 posts |
aaaa |