subs {freegroup} | R Documentation |
Substitute and invert symbols
Description
Substitute and invert specific symbols in a free object
Usage
subsu(X, from, to)
subs(X, ...)
flip(X, turn)
Arguments
X |
Object of class |
from , to , turn |
Objects coerced to class |
... |
Named arguments for substitution |
Details
Function subsu(X,from,to)
takes object X
and transforms
every symbol present in from
into the symbol specified in
to
.
Function flip(X,turn)
takes object X
and replaces every
symbol present in turn
with its inverse.
Function discard()
, documented at keep.Rd
, effectively
substitutes a symbol with the identity element (thereby discarding
it).
Experimental function subs()
is modelled on similar
functionality in the freealg package and makes idiom such as
subs(X,a='z')
work as expected (viz, taking each instance of
symbol a
and replacing it with x
).
Note
Functions subs()
and subsu()
substitute for particular
symbols, not free group elements. In particular, be careful with
uppercase (inverse) symbols; because the power is discarded,
substituing with x
is the same as substituting for X
.
This behaviour might change in the future.
Author(s)
Robin K. S. Hankin
See Also
Examples
subsu(abc(1:10),abc(5),'z')
flip(abc(1:10),abc(5))
o <- rfree(30,5,10)
# Following tests should all be TRUE:
size(flip(o,'a')) == size(o)
number(flip(o,'a')) == number(o)
total(flip(o,'a')) == total(o)
size(subsu(o,'a','b')) <= size(o)
number(subsu(o,'a','b')) <= number(o)
total(subsu(o,'a','b')) <= total(o)
frog <- rfree()
subs(frog,a='x')