[m-rev.] for review: add some functions to integer.m and rational.m

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 16 16:14:03 AEDT 2003


On 16-Dec-2003, Julien Fischer <juliensf at students.cs.mu.OZ.AU> wrote:
> 
> Add some functions to the integer and rational modules.
> 
> Clean up the code in these modules so it adheres more closely to
> our current coding standards.
...
> Index: library/integer.m
...
> +:- pred chop(int::in, digit::out, digit::out) is det.
> 
> -:- pred chop(int, digit, digit).
> -:- mode chop(in, out, out) is det.
>  chop(N, Div, Mod) :-
> -    %Div = N div base,
> -    %Mod = N mod base.
>      Div = N >> log2base,
>      Mod = N /\ basemask.

Please keep the comments.
Although they would be better laid out like this:

	chop(N, Div, Mod) :-
	      Div = N >> log2base,	% i.e. Div = N div base
	      Mod = N /\ basemask.	% i.e. Mod = N mod base

> +++ library/rational.m	16 Dec 2003 03:52:04 -0000
...
> @@ -30,10 +32,17 @@
>  :- pred rational:'>='(rational, rational).
>  :- mode rational:'>='(in, in) is semidet.

While you're converting this to modern coding styles, please replace the
":"s here with "." (or just delete the module qualifier).

> @@ -108,88 +125,82 @@
>  % rational__float(r(Num, Den)) =
>  %	float:'/'(integer__float(Num), integer__float(Den)).
> 
> -one = r(integer(1), integer(1)).
> +rational__one = r(integer(1), integer(1)).
> 
> -zero = r(integer(0), integer(1)).
> +rational__zero = r(integer(0), integer(1)).

I thought you wanted to use integer__zero and integer__one?

Otherwise that looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list