Simple question
From: Paul (paul_nospam_at_laberg.com.au)
Date: 02/15/04
- Previous message: Arun Hallan: "Help with project"
- Next in thread: Bart Demoen: "Re: Simple question"
- Reply: Bart Demoen: "Re: Simple question"
- Reply: Paul: "Re: Simple question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 15 Feb 2004 11:14:39 +1100
Using SWI-Prolog, my program reads as follows...
*************
basicpart(rim). basicpart(rearframe). basicpart(gears). basicpart(nut).
basicpart(spoke). basicpart(handles). basicpart(bolt). basicpart(fork).
assembly(bike,[wheel,wheel,frame]).
assembly(wheel,[spoke,rim,hub]).
assembly(frame,[rearframe,frontframe]).
assembly(frontframe,[fork,handles]).
assembly(hub,[gears,axle]).
assembly(axle,[bolt,nut]).
partsof(X,[X]) :- basicpart(X).
partsof(X,P) :-
assembly(X,Subparts),
partsoflist(Subparts,P).
partsoflist([P|Tail],Total) :-
partsof(P,Headparts),
partsoflist(Tail,Tailparts),
append(Headparts,Tailparts,Total).
*************
I try and test the progam with :
partsof(axle,X).
But it keeps coming back with "No"
If somebody is feeling really generous perhaps they also can tell me how the
problem (above) can be seen from the following debug trace:
[debug] 7 ?- partsof(axle,X).
Call: (7) partsof(axle, _G490) ? creep
Call: (8) basicpart(axle) ? creep
Fail: (8) basicpart(axle) ? creep
Redo: (7) partsof(axle, _G490) ? creep
Call: (8) assembly(axle, _L182) ? creep
Exit: (8) assembly(axle, [bolt, nut]) ? creep
Call: (8) partsoflist([bolt, nut], _G490) ? creep
Call: (9) partsof(bolt, _L195) ? creep
Call: (10) basicpart(bolt) ? creep
Exit: (10) basicpart(bolt) ? creep
Exit: (9) partsof(bolt, [bolt]) ? creep
Call: (9) partsoflist([nut], _L196) ? creep
Call: (10) partsof(nut, _L233) ? creep
Call: (11) basicpart(nut) ? creep
Exit: (11) basicpart(nut) ? creep
Exit: (10) partsof(nut, [nut]) ? creep
Call: (10) partsoflist([], _L234) ? creep
Fail: (10) partsoflist([], _L234) ? creep
Redo: (10) partsof(nut, _L233) ? creep
Call: (11) assembly(nut, _L252) ? creep
Fail: (11) assembly(nut, _L252) ? creep
Fail: (9) partsoflist([nut], _L196) ? creep
Redo: (9) partsof(bolt, _L195) ? creep
Call: (10) assembly(bolt, _L214) ? creep
Fail: (10) assembly(bolt, _L214) ? creep
Fail: (8) partsoflist([bolt, nut], _G490) ? creep
Thanks for the help
- Previous message: Arun Hallan: "Help with project"
- Next in thread: Bart Demoen: "Re: Simple question"
- Reply: Bart Demoen: "Re: Simple question"
- Reply: Paul: "Re: Simple question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|