[m-dev.] for review: extra modes for random.m
Ralph Becket
rbeck at microsoft.com
Thu Mar 1 00:44:18 AEDT 2001
Estimated hours taken: 0.4
library/random.m:
Added support for in/out random__supply arguments to
complement the existing mdi/muo modes. This is useful
when a random__supply is a component of a non-(mostly-)
unique object.
Index: random.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/random.m,v
retrieving revision 1.19
diff -u -r1.19 random.m
--- random.m 2000/09/25 08:25:00 1.19
+++ random.m 2001/02/28 13:33:30
@@ -36,18 +36,21 @@
% binds RS to the new state of the random number supply.
:- pred random__random(int, random__supply, random__supply).
:- mode random__random(out, mdi, muo) is det.
+:- mode random__random(out, in, out) is det.
% random__randmax(RandMax, RS0, RS): binds Randax to the maximum
% random number that can be returned from the random number
% supply RS0, and returns RS = RS0.
:- pred random__randmax(int, random__supply, random__supply).
:- mode random__randmax(out, mdi, muo) is det.
+:- mode random__randmax(out, in, out) is det.
% random__permutation(List0, List, RS0, RS):
% binds List to a random permutation of List0,
% and binds RS to the new state of the random number supply.
:- pred random__permutation(list(T), list(T), random__supply,
random__supply).
:- mode random__permutation(in, out, mdi, muo) is det.
+:- mode random__permutation(in, out, in, out) is det.
%---------------------------------------------------------------------------
%
@@ -106,10 +109,12 @@
Len = array__size(Samples),
perform_sampling(Len, Samples, [], List, RS0, RS).
-:- pred perform_sampling(int::in, array(T)::array_di,
- list(T)::in, list(T)::out,
- random__supply::mdi, random__supply::muo) is det.
+:- pred perform_sampling(int, array(T), list(T), list(T),
+ random__supply, random__supply) is det.
+:- mode perform_sampling(in, array_di, in, out, mdi, muo) is det.
+:- mode perform_sampling(in, array_di, in, out, in, out) is det.
+
perform_sampling(I, Record0, Order0, Order, RS0, RS) :-
( I =< 0 ->
Order = Order0,
@@ -137,6 +142,7 @@
:- pred random__test_2(int, list(int), random__supply, random__supply).
:- mode random__test_2(in, out, mdi, muo) is det.
+:- mode random__test_2(in, out, in, out) is det.
random__test_2(N, Is, RS0, RS) :-
(
-- Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list