[][src]Type Definition free_algebra::FreeMonoid

type FreeMonoid<C> = MonoidalString<C, ()>;

A monoid constructed from free multiplication of elements of a set

Concretely, given a set C, we construct the free-monoid of C as the set of all finite lists of members of C where multiplication is given by concatenation. In other words, it's basically Vec<C> but with a*b == {a.append(&mut b); a}.

Examples

use maths_traits::algebra::One;
use free_algebra::FreeMonoid;

let s1 = FreeMonoid::one() * 'a' * 'b' * 'c';
let s2 = s1.clone().reverse();

assert_eq!(s1, ['a','b','c']);
assert_eq!(s2, ['c','b','a']);

let mul = s1 * s2;

assert_eq!(mul, ['a','b','c','c','b','a']);