Re:Calculate the difference and intersection of any two regexes
by yorwba on Monday September 11, 2023 @05:41PM
(#37474108)
Seems like it should at least be x(|x(|x(|x))) instead of x|xx|xxx|xxxx to avoid quadratic blow-up.
Re:Calculate the difference and intersection of any two regexes
by d66 on Monday September 11, 2023 @05:50PM
(#37474195)
yes, that is the actual construction: the disjunction data type only supports a lhs and rhs, so that is the only possible way to represent it.
i wrote it the way i did for clarity in the comments.
this simplifies the code for testing equality and inclusion, since logically x{n} is just xx... (n times) and x{m,n} is just x{m}|x{m+1}|...|x{n}.
but when you have x{m,n} and n-m is large you can imagine what kind of problems that causes.