as.function.permutation | R Documentation |
Coerce a permutation to an executable function
## S3 method for class 'permutation' as.function(x, ...)
x |
permutation |
... |
further arguments (currently ignored) |
Multiplication of permutations loses associativity when using functional notation; see examples.
Also, note that the coerced function will not take an argument greater than the size (qv) of the permutation.
Robin K. S. Hankin
x <- cyc_len(3) y <- cyc_len(5) xfun <- as.function(x) yfun <- as.function(y) stopifnot(xfun(yfun(2)) == as.function(y*x)(2)) # note transposition of x & y # written in postfix notation one has the very appealing form x(fg) = (xf)g # it's vectorized: as.function(rperm(10,9))(1) as.function(as.cycle(1:9))(sample(9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.