Open krader1961 opened 4 years ago
Revisiting this issue I'm still inclined to introduce a random
module and move the two builtins to that module. Specifically: builtin:rand
=> random:float
and builtin:randint
=> random:int
. Then introduce other useful commands such as random:shuffle $list
and random:pick $list
.
Note that commit 46008d1 introduced a -randseed
command with this commit comment:
This command is prefixed with - since I'd like to eventually move rand and randint into their own module, so this command will be moved too.
I'm still inclined to introduce a random
module and move these functions to that module.
Should the
rand
andrandint
commands be moved to themath:
namespace? Or, alternatively, should arandom:
namespace be implemented that includes equivalents of those commands as well as more sophisticated commands? For example, something likerandom:choice
to pick a random element from a sequence such as a list or map? This is a case where I think the Pythonrandom
module is a better model for Elvish than the Gomath/rand
package. For example, alist = (random:shuffle $list)
could be useful.This is something that needs a lot of discussion so I'm not going to create a pull-request despite my inclination to create a
random:
namespace.