Mercurial > hg > Applications > Tokio
diff Examples/multiply/multi2 @ 0:cfb7c6b24319
Initial revision
author | kono |
---|---|
date | Thu, 30 Aug 2007 14:57:44 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Examples/multiply/multi2 Thu Aug 30 14:57:44 2007 +0900 @@ -0,0 +1,22 @@ +main :- read((In1,In2)), + mult_imp4(In1,In2,M,N,Done), + #write((Done,M,N)). + +mult_imp4(In1,In2,M,N,Done) :- + #stable(In1),#stable(In2), + @ ( + M = In2, + N = In1, + Done = 0, + int1(In1,In2,Done,M,N) + ). + +int1(In1,In2,Done,M,N) :- + halt(Done=1), + intN(In2,Done,M,N). + +intN(In2,Done,M,N) :- + @M = M+In2, + @N = N-1, + (if N-2=0 then @Done=1 else @Done=0), + next(intN(In2,Done,M,N)).