users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: too simple trace


From: Daniel Diaz
Subject: Re: too simple trace
Date: Tue, 29 Apr 2003 12:29:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01

Note that permutation/2 and select/3 are predefined predicates (built-in). They are compiled (native code) and thus you cannot trace them. Simply rename permuntation as perm (and select as sel). And, after loading under the top-level (with consult), you will be able to trace them.

Good luck


Gilles Dégottex wrote:
Hi all

        I think gprolog does a too much simple trace on this exemple:

permutation([], []).
permutation(List, [S|Perm]) :-
        select(S, List, Rest),
        permutation(Rest, Perm).

select(Element, [Element|Tail], Tail).
select(Element, [Head|Tail1], [Head|Tail2]) :-
        select(Element, Tail1, Tail2).

=>
"
Prolog interruption (h for help) ? t
The debugger will first creep -- showing everything (trace)
| ?- permutation([1, 2, 3], L).
      1    1  Call: permutation([1,2,3],_23) ?
      1    1  Exit: permutation([1,2,3],[1,2,3]) ?

L = [1,2,3] ?

yes
{trace}
| ?-
"

no call to select, and no different trace if I press "shift+;" for the other solutions. maybe I missed an option

I thought it was a nice exemple for studients, to show the backtraking engine, since they saw these two lines :)

Tanks for comments
Gilles



_______________________________________________
Users-prolog mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/users-prolog

--
Ce message a subi une analyse antivirus par MailScanner ; il est vraisemblablement
sans danger.






--
Ce message a subi une analyse antivirus par MailScanner ; il est vraisemblablement
sans danger.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]