On Thu, Feb 10, 2022 at 6:27 PM Alexander Burger <a...@software-lab.de> wrote:
> > Could not resist. I elaborated a little :) > > If we define '+' as > > (be + (@A @B @C) > (^ @C (+ @A @B)) T ) > > (be + (@A @B @C) > (^ @B (- @C @A)) T ) > > (be + (@A @B @C) > (^ @A (- @C @B)) T ) > > (be + (@A 0 @A)) > > (be + (@A @B @C) > (^ @Z (dec @C)) > (+ @A @Y @Z) > (^ @B (inc @Y)) ) > > then we can use it as > > : (? (+ 3 4 @X)) > @X=7 > > : (? (+ 3 @X 7)) > @X=4 > > : (? (+ @X 4 7)) > @X=3 > > : (? (+ @X @Y 7)) > @X=7 @Y=0 > @X=6 @Y=1 > ... > > I suppose pilog search for rules in order, so the goal (? (+ 3 @X 7)) always matches first three rules with the cut, but shouldn't the last goal match also one of the first three line thus avoiding backtracking? I think I don't fully understand how it works. Also, when a goal return a non terminating list, what happend if we try the function solve with it? is there any way to get an exception or a stream? regards