Learn R Programming

pracma (version 1.2.5)

perms: Generate Permutations

Description

Generates all permutations of a vector a.

Usage

perms(a)

Arguments

a
numeric vector of some length n

Value

  • matrix of permutations of the elements of a

Details

If 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.

See Also

randperm

Examples

Run this code
perms(6)
perms(1:6)
perms(c(1, exp(1), pi))

Run the code above in your browser using DataLab