keepcyc: Keep or discard some cycles of a permutation

keepcycR Documentation

Keep or discard some cycles of a permutation

Description

Given a permutation and a function that returns a Boolean specifying whether a cycle is acceptable, return a permutation retaining only the acceptable cycles.

Usage

keepcyc(a, func, ...)

Arguments

a

Permutation, coerced to cycle

func

Function to be applied to each element of a

...

Further arguments to fun()

Value

Returns a permutation in cycle form

Note

Function keepcyc() is idempotent.

Author(s)

Robin K. S. Hankin

See Also

allcyc

Examples


keepcyc(rgivenshape(10,2:8),function(x){length(x) == 2})  # retains just transpositions
keepcyc(megaminx,function(x){any(x == 100)})              # retains just cycles modifying facet #100
keepcyc(rperm(100),function(x){max(x)-min(x) < 3})        # retains just cycles with range<3

f <- function(x, p){all(x < p) || all(x > p)}             # keep only cycles with all entries either
keepcyc(rgivenshape(9,rep(2:3,9)), f, p=20)               #  all < 20 or all >20


permutations documentation built on July 13, 2026, 5:07 p.m.