newbie question: debugging technique
From: chenyu (chenyu468_at_yahoo.com)
Date: 02/16/04
- Next message: Paul Singleton: "Re: Egg on my face, I guess I still have trouble with declarative thinking at times."
- Previous message: chenyu: "newbie question, swi-prolog"
- Next in thread: Alan Bal jeu: "Re: newbie question: debugging technique"
- Reply: Alan Bal jeu: "Re: newbie question: debugging technique"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Feb 2004 01:03:01 -0800
Hello everyone,
I am writing the "depth-first search" program and found the debugging
is difficult to me when recursion is used and program is a little
long.
%my program:
depthfirst1([Head|CandidatePath],[Head|CandidatePath]):-
goal(Head),!.
depthfirst1([Head|CandidatePath],Solution):-
s(Head,Next),
not(member(Next,[Head|CandidatePath])),
depthfirst1(CandidatePath,Solution).
s(Queens,[Queen|Queens]):-
member(Queen,[1,2,3,4,5,6,7,8]),
noattack(Queen,Queens,1).
goal([_,_,_,_,_,_,_,_]).
solve2(Node,Solution):-
depthfirst1([Node],Solution).
%my goal
solve2([],X).
My goal always return me "No".
1. Therefore I want to check every time "depthfirst1"'s unify result,
then decide at which level the error happens?
1.1 Does my debugging logic is correct?
1.2 Does it mean to trace "unify port" of predicate "depthfirst1"?
1.3 could I write trace(depthfirst1,+unify),trace,solve2([],X)?
2. What's the difference between trace point and spy point?
Thank you for your attention.
kind regards
chenyu
- Next message: Paul Singleton: "Re: Egg on my face, I guess I still have trouble with declarative thinking at times."
- Previous message: chenyu: "newbie question, swi-prolog"
- Next in thread: Alan Bal jeu: "Re: newbie question: debugging technique"
- Reply: Alan Bal jeu: "Re: newbie question: debugging technique"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|