Saturday 15 March 2014

swi Prolog tracing recursion depth -



swi Prolog tracing recursion depth -

why recursion depth start 6 or 7 when tracing prolog programs?

example (taken form here).

factorial(0, 1). factorial(n, nfact) :- n > 0, nminus1 n - 1, factorial(nminus1, nminus1fact), nfact nminus1fact * n.

lets trace factorial(3, x). output is:

call: (7) factorial(3, _g284) ? creep* call: (8) 3>0 ? creep exit: (8) 3>0 ? creep call: (8) _l205 3-1 ? creep

and on. first column (call, exist) ports, 3rd goals , sec recursion depth. why start 7? (when run illustration on machine starts 6) shouldn't rather start 1 or 0?

prolog tracing factorial

No comments:

Post a Comment