Another try
From: Yereth Jansen (yereth.no_at_spam.wanadoo.nl)
Date: 02/07/05
- Previous message: Yereth Jansen: "Re: Problem with short deadline"
- Next in thread: estevedelacebo_at_gmail.com: "Re: Another try"
- Reply: estevedelacebo_at_gmail.com: "Re: Another try"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 07 Feb 2005 00:29:36 +0100
Sorry for double posting, but my latest answer wasn't exactly useful and
I am in quite a hurry. Not of your concern perhaps, but the more for me
though.
I know out of experience that people tend to skip posts that have
replies already, so below another time my question:
---
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
- Previous message: Yereth Jansen: "Re: Problem with short deadline"
- Next in thread: estevedelacebo_at_gmail.com: "Re: Another try"
- Reply: estevedelacebo_at_gmail.com: "Re: Another try"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]