regex.pl 439 B

12345678910111213141516
  1. matches(\varepsilon, []).
  2. matches(C, [C]) :- atom(C), !.
  3. matches(\cup(A, _), S) :- matches(A, S).
  4. matches(\cup(_, B), S) :- matches(B, S).
  5. matches(\cdot(A, B), S) :- append(S1, S2, S),
  6. matches(A, S1),
  7. matches(B, S2).
  8. matches(*(_), []).
  9. matches(*(A), S) :- append(S1, S2, S),
  10. not(S1=[]),
  11. matches(A, S1),
  12. matches(*(A), S2).