Haskell + hgl, 18 bytes
or<xQ iw<sj<sYe"|" Explanation
sYe"|"split along|ssjsort by ascending lengthxQ iwfor each pair of items give whether the first is an infix of the second.oror over the results
We need to sort the list because xQ compares only pairs where the first item comes before the second. Since to be an infix a string must be shorter, we sort by length.
Reflection
It feels like we just miss a much shorter answer in a bunch of ways.
- There should be a reflexive version of
iw. If this were the case we could really shorten things. This would save us from having to sort the list. - There should at least be a function to "reflexivize" an operator, so that if this happens again where I want a reflexive version of an operator I can make it relatively cheaply. This probably wouldn't save bytes here, but there might not be the same sorting trick in the future.
xQtakes all pairs where the first item appears before the second and applies a function. If there was a function which takes all pairs other than those on the diagonal that would also save us from having to sort the list.- There should be a version of
xQwhich automatically combines the results. There's alreadyepaforpain the same module, so this seems like an oversight. - I could probably have versions of
sYepreloaded with various character classes. For this both "split along non-alphabetic" and "split along symbols" would work, and are probably sufficiently useful to justify their creation. - There should be a function to count the number of times something appears as an infix. Another way to solve this problem should be to ask whether any of the words appears more than once in the original regex.