From previous thread:
The cyclic comparison uses the same trick as for cyclic unification I learned from Bart Demoen and that is described in pl-prims.c in a comment starting at line 71. The idea is that while going through compounds you create a reference link from the compound at one side to the other one. Now, for unification and ==/2
this works fine as the argument order does not matter. For comparison, the argument order does matter.
Now, is there a fundamentally better (not so easy to define what is better) algorithm? Is it possible to improve on the current algorithm, possibly by keeping track of the “side” we are?
Anyone wishing to sort it out, see pl-prims.c
, do_compare() It surely is an interesting finding. Is there a pointer to the original discussion?
I had a quick look at do_compare()
but it’s beyond my capabilities to figure out what’s going on. Somebody with a better understanding of the C FLI might have a chance.