a
.perms(a)
n
a
a
is a vector of length n
, generate all permutations
of the elements in a
as a matrix of size n! x n
where
each row represents one permutation.A matrix will be expanded as vector.
randperm
perms(6)
perms(1:6)
perms(c(1, exp(1), pi))
Run the code above in your browser using DataLab