import vcsn
c = vcsn.context('lal, q')
c
p = c.polynomial('<2>a + <3>b')
p
p.rweight(c.weight('4'))
Instead of p.rweight(w)
, you may write w * p
.
p * c.weight('4')
You may even run the simpler:
p * 4
In the following polynomial, note that 2 and 3 are weights in the polynomial, but 5 is a weight in the expression.
c = vcsn.context('expressionset<lal, q>, q')
c
p = c.polynomial('<2>a*') + c.polynomial('<3><5>b*')
p
p * 4
This is very different from left-scalar product.
4 * p