[m-users.] The new random module(s)

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Sep 6 15:12:43 AEST 2019



On Thu, 5 Sep 2019 21:09:17 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:

> 
> Hi Mark,
> 
> On Thu, 5 Sep 2019, Mark Brown wrote:
> 
> > On Thu, Sep 5, 2019 at 4:09 PM Julian Fondren <jfondren at minimaltype.com> wrote:
> >>
> >> In the permute_array/permute_list future,
> >> will permute_X be added for other data structures?
> >
> > I wasn't planning to. Permutation is (mathematically) usually only
> > defined for sets and sequences so I'm not sure what you'd be expecting
> > for other library types. I suppose there could be a set permutation
> > predicate that returns a randomly ordered list of the elements.
> >
> > In my view, the reason to put them in the random module is that they
> > are more related to each other, and to the other predicates that do
> > random stuff, than they are to predicates that merely work on lists or
> > arrays. But no matter, I can add list.random_permutation now unless
> > anyone else wants to add their opinion?
> 
> I disagree: I expect to find generic operations on lists in the list
> module and generic operations on arrays in the array module.

For me, when I think of generic operations on lists or arrays, random shuffling
never enters my mind. I am guessing Mark's preference for locating these
operations in the random module also comes from this: randomness has
nothing to do with the usual operations on lists or arrays.

> I think we could avoid the namespace issues by naming the new versions
> either:
> 
> 
>      random.shuffle_list
>      random.shuffle_array
> 
> or:
> 
>      list.random_shuffle
>      array.randome_suffle
> 
> depending on where they end up (i.e. don't use the word permutation
> or permute.)

Agreed, though of course I prefer the former pair of names.

Zoltan.


More information about the users mailing list