Re:Python code to solve xkcd 1313 by Peter Norvig
by sushirain on Tuesday January 07, 2014 @05:30AM
(#7016541)
What would be a use for finding a minimal discriminating regex? Perhaps understanding the difference between boys' and girls' names?
[ Parent
| on HN ]
Re:Python code to solve xkcd 1313 by Peter Norvig
by bjourne on Tuesday January 07, 2014 @06:57AM
(#7016810)
Performance. For example if you are syntax highlighting a programming language with hundreds of keywords, then using a regexp like "(kwd1|kwd2|...|kwdn)" is not very efficient. An optimized regexp can do the same matching much faster.
Re:Python code to solve xkcd 1313 by Peter Norvig
by jules on Tuesday January 07, 2014 @11:40AM
(#7018174)
You would be much better off just generating the DFA of the straightforward regex and minimizing that DFA. This is simpler and faster to generate and faster to execute. Furthermore, in a parser for a programming language you do not want to match some things in one list but not in this other list, you want to match some things in this list and nothing else.