Closed 4meta5 closed 3 years ago
just fixed it by adding constraint length(T,Z),Z>0
so the code is now
arithmetic([X,Y],Q) :-
Q is Y-X.
arithmetic([X,Y|T],Q) :-
length(T,Z),Z>0,
arithmetic([X,Y],Q),
arithmetic([Y|T],Q).
geometric([X,Y],Q) :-
Q is Y/X.
geometric([X,Y|T],Q) :-
length(T,Z),Z>0,
geometric([X,Y],Q),
geometric([Y|T],Q).
This is a problem with
arithmetic
which bleeds into other code. Why doesn't this fail earlier? Some infinite recursion here, but I'd like it to fail the first time that the difference sequence is shown to not be constant....QUERY:
Originally posted by @4meta5 in https://github.com/4meta5/reconocer/issues/1#issuecomment-727739994