Problem 7.2

Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.

Problem 7.2
Hey, for me it seems like that the fixity parameters in the definitions of the connectives are not correct, as the example here shows:

test(X>Y):- writeln(X), writeln(Y).

?- test(a>b>c>d).
a>b>c
d
true.

I think that when matching [m]a>b>c>d[/m] with [m]X>Y[/m], [m]X[/m] should be [m]a[/m] ?


Nope, implication is left-associative (yfx), i.e. a>b>c>d is parsed as (((a>b)>c)>d), which means prolog pattern-matches correctly :wink:


ah, wait, but it should be right-associative… sorry, I always get confused. Which is why I strongly prefer to just use brackets when dealing with non-associative connectives.

Yes, you can fix that (apparently) by using xfy instead of yfx.