powered by
Length-2 cycles; swap a pair of elements
swap(a, b)
Returns a permutation in cycle form
Integers
Robin K. S. Hankin
Swaps two elements. Vectorized; uses standard recycling.
as.cycle
swap(2, 8) swap(5, 1:9) swap(1:8, 8:1) swap(sample(9), sample(9)) rcyc(10,4)^swap(1,9)
Run the code above in your browser using DataLab