I get Stack limit exceeded in Prolog using append
I'am writing a spanish grammar and need to use append to separate clausules (to separate subject and predicate, get verbs, etc...).
Here I write a simplified use of append that I do not understand why is overflow. I get the answers that I want, but then loops to infinity and beyond!
complejidad(1,0).
complejidad(2,0).
complejidad(2,1).
lista(['A'], 0).
lista(['B'], 0).
lista(Frase, J) :-
lista(Prefijo, 0),
lista(Sufijo, Js),
append(Prefijo, Sufijo, Frase),
complejidad(J, Js).
If I query:
lista(X,_)
Y put the comlejidad statement to limit the recursion a 2 steps. But something happends with append.
Here is the live example: https://swish.swi-prolog.org/p/stack-limit-exceeded-with-append.pl
And here is my grammar: https://swish.swi-prolog.org/p/mini-gramatica-castellana.v2.pl
I show my grammar to ilustrate why I need append!
