subs: Substitute and invert symbols

subsR Documentation

Substitute and invert symbols

Description

Substitute and invert specific symbols in a free object

Usage

subs(a, from, to)
flip(a, turn)

Arguments

a

Object of class free

from,to,turn

Objects coerced to class free specifying symbols to alter. These arguments are coerced to symbols using getlet(as.free())

Details

Function subs(a,from,to) takes object a and transforms every symbol present in from into the symbol specified in to.

Function flip(a,turn) takes object a 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).

Note

Function subs() substitutes for particular symbols, not free group elements.

Author(s)

Robin K. S. Hankin

See Also

abs,discard

Examples


subs(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(subs(o,'a','b'))   <= size(o)
number(subs(o,'a','b')) <= number(o)
total(subs(o,'a','b'))  <= total(o)



freegroup documentation built on Dec. 28, 2022, 2:14 a.m.