Problem with '>='
From: Dominik Off (Dominik.Off_at_epost.de)
Date: 12/08/03
- Next message: Kenny Mees: "Compare time"
- Previous message: Fergus Henderson: "Re: newbie question"
- Next in thread: Brian: "Re: Problem with '>='"
- Reply: Brian: "Re: Problem with '>='"
- Reply: Jens Kilian: "Re: Problem with '>='"
- Reply: Nick Wedd: "Re: Problem with '>='"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 8 Dec 2003 19:27:15 +0100
I wrote the following prolog program:
<code>
%Rekursionsabschluß
b1(0,[H0|B0],[H0|B0],[_|BM]):- BM == [].
b1(Betrag,[H0|BO],[HX|BX],[HM|BM]):- Betrag >= HM , Betrag1 is (Betrag -
HM) ,
H01 is H0 + 1,
b1(Betrag1,[H01|BO],[HX|BX],[HM|BM]).
b1(Betrag,[H0|BO],[HX|BX],[HM|BM]):- Betrag <
HM,b1(Betrag,[0|[H0|BO]],[HX|BX],BM).
w(X,Y):-b(X,[0,0,0,0,0,0,0,0],Y).
% w1(Geldbetrag in Cent,Münzausgabe).
w1(X,Y):-X1 is X , b1(X1,[0],Y,[2,1,0.5,0.2,0.1,0.05,0.02,0.01]).
</Code>
And in Trace Mode:
[trace] 56 ?- w1(0.7,X).
Call: (7) w1(0.7, _G404) ? creep
^ Call: (8) _L182 is 0.7 ? creep
^ Exit: (8) 0.7 is 0.7 ? creep
Call: (8) b1(0.7, [0], _G404, [2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01]) ?
creep
^ Call: (9) 0.7>=2 ? creep
^ Fail: (9) 0.7>=2 ? creep
Redo: (8) b1(0.7, [0], _G404, [2, 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01]) ?
creep
^ Call: (9) 0.7<2 ? creep
^ Exit: (9) 0.7<2 ? creep
Call: (9) b1(0.7, [0, 0], [_G514|_G515], [1, 0.5, 0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (10) 0.7>=1 ? creep
^ Fail: (10) 0.7>=1 ? creep
Redo: (9) b1(0.7, [0, 0], [_G514|_G515], [1, 0.5, 0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (10) 0.7<1 ? creep
^ Exit: (10) 0.7<1 ? creep
Call: (10) b1(0.7, [0, 0, 0], [_G514|_G515], [0.5, 0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (11) 0.7>=0.5 ? creep
^ Exit: (11) 0.7>=0.5 ? creep
^ Call: (11) _L244 is 0.7-0.5 ? creep
^ Exit: (11) 0.2 is 0.7-0.5 ? creep
^ Call: (11) _L245 is 0+1 ? creep
^ Exit: (11) 1 is 0+1 ? creep
Call: (11) b1(0.2, [1, 0, 0], [_G514|_G515], [0.5, 0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (12) 0.2>=0.5 ? creep
^ Fail: (12) 0.2>=0.5 ? creep
Redo: (11) b1(0.2, [1, 0, 0], [_G514|_G515], [0.5, 0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (12) 0.2<0.5 ? creep
^ Exit: (12) 0.2<0.5 ? creep
Call: (12) b1(0.2, [0, 1, 0, 0], [_G514|_G515], [0.2, 0.1, 0.05, 0.02,
0.01]) ? creep
^ Call: (13) 0.2>=0.2 ? creep <----------------
^ Fail: (13) 0.2>=0.2 ? creep <----------------
Look at the last two lines! Why isn't 0.2 greater or equal than 0.2 !?
-- Dominik Off
- Next message: Kenny Mees: "Compare time"
- Previous message: Fergus Henderson: "Re: newbie question"
- Next in thread: Brian: "Re: Problem with '>='"
- Reply: Brian: "Re: Problem with '>='"
- Reply: Jens Kilian: "Re: Problem with '>='"
- Reply: Nick Wedd: "Re: Problem with '>='"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]