4meta5 / reconocer

recognize relations from integer sequences
MIT License
0 stars 0 forks source link

basics #1

Closed 4meta5 closed 3 years ago

4meta5 commented 3 years ago

linear homogenous eq of deg2

arithmetic and geometric sequences

special sequences

4meta5 commented 3 years ago

This is a problem with arithmetic which bleeds into other parts of the 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....

arithmetic([X,Y],Q) :-
    Q is Y-X.
arithmetic([X,Y|T],Q) :-
    arithmetic([X,Y],Q),
    arithmetic([Y|T],Q).

QUERY:

?- arithmetic([1,4,16,64],Q).
ERROR: Stack limit (1.0Gb) exceeded
ERROR:   Stack sizes: local: 0.5Gb, global: 0.2Gb, trail: 5Kb
ERROR:   Stack depth: 5,162,016, last-call: 0%, Choice points: 3
ERROR:   In:
ERROR:     [5,162,016] user:arithmetic([length:2], 3)
ERROR:     [5,162,015] user:arithmetic([length:2], 3)
ERROR:     [5,162,014] user:arithmetic([length:2], 3)
ERROR:     [5,162,013] user:arithmetic([length:2], 3)
ERROR:     [5,162,012] user:arithmetic([length:2], 3)
ERROR: 
ERROR: Use the --stack_limit=size[KMG] command line option or
ERROR: ?- set_prolog_flag(stack_limit, 2_147_483_648). to double the limit.