[mercury-users] abstract types.
Juergen Stuber
juergen at mpi-sb.mpg.de
Wed Jan 19 01:03:19 AEDT 2000
Peter Schachte <schachte at cs.mu.OZ.AU> writes:
>
> I've just submitted a new predicate for the int library module:
>
> % code(Factor, Value, Residue, Coding)
> % holds iff Factor*Value+Residue = Coding, and 0 <= Value < Factor.w
> % This is useful for things like converting between time as
> % hours, minutes, and seconds, and raw seconds.
>
> :- pred code(int, int, int, int).
> :- mode code(in, in, in, out) is det.
> :- mode code(in, out, out, in) is det.
The name code is a bit unspecific IMHO. Why don't you call
it divmod, since it is division with remainder backwards:
% divmod(Value, Divisor, Quotient, Residue)
% holds iff Value = Divisor*Quotient+Residue and 0 <= Residue < Divisor
:- pred divmod(int, int, int, int).
:- mode divmod(in, in, out, out) is det.
:- mode divmod(out, in, in, in) is det.
It is also useful to have a combined div and mod, since division
algorithms tend to produce quotient and residue simultaneously,
and calling div and mod separately executes them twice.
J|rgen
--
J|rgen Stuber <juergen at mpi-sb.mpg.de>
http://www.mpi-sb.mpg.de/~juergen/
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list