The package provides methods to invert objects of class word
(the R idiom is W[W] <- seq_along(W)
) and also objects of class
cycle
(the idiom is
lapply(cyc,function(o){c(o[1],rev(o[-1]))})
).
The user should use inverse()
directly, which dispatches to
either inverse.word()
or inverse.cycle()
as appropriate.
Sometimes, using idiom such as x^-1
or id/x
gives neater
code, although these may require coercion between word form and cycle
form.