[][src]Type Definition free_algebra::FreePowMonoid

type FreePowMonoid<C, P> = MonoidalString<FreePow<C, P>, PowRule>;

The free multiplication of members of type C raised to some power

The primary use-case of this is to compress the storage requirements of a FreeGroup or FreeMonoid by grouping repeated elements with an integral exponent, but other, more exotic, exponents are supported as well

Examples

use free_algebra::{FreePowMonoid, FreePow};

let x = FreePow('a', 1) * FreePow('a', 2) * FreePow('b', 1) * FreePow('a', 2);
let y = FreePow('a', -2) * FreePow('b', 1);

assert_eq!(x, [FreePow('a', 3), FreePow('b', 1), FreePow('a', 2)]);
assert_eq!(y, [FreePow('a', -2), FreePow('b', 1)]);
assert_eq!(x*y, [FreePow('a', 3), FreePow('b', 2)]);