Skip to content

Commit d3529a3

Browse files
Make Random for a (finite) collection take an optional source
This requires moving the function as it was defined too early to use InstallMethodWithRandomSource
1 parent f0f332b commit d3529a3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

lib/coll.gi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,15 @@ InstallGlobalFunction( RandomList, function(args...)
257257
Error(" Usage: RandomList([rs], list))");
258258
fi;
259259
end );
260-
InstallMethod( Random, "for a (finite) collection",
261-
[ IsCollection and IsFinite ],
262-
C -> RandomList( Enumerator( C ) ) );
263260

264-
RedispatchOnCondition(Random,true,[IsCollection],[IsFinite],0);
265261

262+
InstallMethodWithRandomSource( Random,
263+
"for a random source and a (finite) collection",
264+
[ IsRandomSource, IsCollection and IsFinite ],
265+
{rs, C} -> RandomList(rs, Enumerator( C ) ) );
266+
267+
RedispatchOnCondition(Random,true,[IsCollection],[IsFinite],0);
268+
RedispatchOnCondition(Random,true,[IsRandomSource,IsCollection],[IsFinite],0);
266269

267270
#############################################################################
268271
##

0 commit comments

Comments
 (0)