Problem with short deadline
From: Yereth Jansen (yereth.no_at_spam.wanadoo.nl)
Date: 02/06/05
- Next message: Bart Demoen: "Re: Problem with short deadline"
- Previous message: Yereth Jansen: "Re: How is select/3 implemented?"
- Next in thread: Bart Demoen: "Re: Problem with short deadline"
- Reply: Bart Demoen: "Re: Problem with short deadline"
- Reply: Mick Krippendorf: "Re: Problem with short deadline"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 06 Feb 2005 17:22:15 +0100
Hello,
I have a problem with a prolog function I've written. The function is
defined as followed:
selectInStorage(
part([A,B,C,Price1]),
[part([A,B,C,Price2])|Tail],
Tail,
Price2
) :-
Price2 =< Price1.
selectInStorage(
part([A1, B1, C1, D1]),
[part([A2, B2, C2, D2]) | Tail],
[part([A2, B2, C2, D2]) | Rest],
_
) :-
selectInStorage(
part([A1, B1, C1, D1]),
Tail,
Rest,
_
).
This is the result of 2 tries in the commandline:
13 ?- selectInStorage(part([a,b,c,500]),[part([a,b,c,450])],List,Price).
List = []
Price = 450
Yes
14 ?- selectInStorage(part([a,b,c,500]),[part([a,b,c,550])],List,Price).
No
15 ?-
selectInStorage(part([a,b,c,500]),[part([a,b,c,550]),part([a,b,c,450])],List,Price).
List = [part([a, b, c, 550])]
Price = _G743
Yes
Now clearly, with the last result we are not getting the price we want.
The price should've been 450. He does find the right result, but does
not output Price2 correctly. Anyone any clue what we are doing wrong here?
Thanks in advance,
Yereth Jansen
- Next message: Bart Demoen: "Re: Problem with short deadline"
- Previous message: Yereth Jansen: "Re: How is select/3 implemented?"
- Next in thread: Bart Demoen: "Re: Problem with short deadline"
- Reply: Bart Demoen: "Re: Problem with short deadline"
- Reply: Mick Krippendorf: "Re: Problem with short deadline"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]