// How do I create a word?
// Create an empty word (identity)
Word e;
cout << "Create an empty word : " << e << endl;
// Create a word from a vector of generators ,
// where xi is a positive or negative integer s.t.
// abs(xi) = 1, ..., n and n is the rank of a group
vector v(4,0); // 4 generators in the vector
// Enter <1,1,-2,-2> which corresponds to a word x1^2 x2^-2 in
v[0] = 1; v[1] = 1; v[2] = -2; v[3] = -2;
// create a word from v
Word wv(v);
cout << "Create a word from a vector of generators : " << wv << endl;
// Create a word from a list of generators ,
list l; // 4 generators in the vector
// Create a list which corresponds to a word (x1 x2)^10 in
for (int i=0;i<10;i++){
l.push_back(1); // append the first generator (see below)
l.push_back(2); // append the second generator
}
// create a word from l
Word wl(l);
cout << "Create a word from a list of generators : " << wl << endl;
// How do I insert letters or subwords into a word
// Insert a sequence of generators [B,E) into a word at th position 5
Word w_tmp = wl;
// w_tmp.insert( 5 , wv.begin(),wv.end() );
// cout << "Insert :" << wl << " -> " << w_tmp << endl;
// Insert a generator x5 into a word after the 5th letter
w_tmp = wl;
w_tmp.insert( 5,5 );
cout << "Insert :" << wl << " -> " << w_tmp << endl;
// Insert a sequence of generators [B,E) into a word before the second position
w_tmp = wl;
WordIterator wI = wl.begin();
// w_tmp.insert::const_iterator>( ++wI,wv.getList().begin(),wv.getList().end() );
//cout << "Insert :" << wl << " -> " << w_tmp << endl;
// Insert a generator x5 into a word before the second position
w_tmp = wl;
wI = w_tmp.begin();
w_tmp.insert( ++wI,5 );
cout << "Insert :" << wl << " -> " << w_tmp << endl;
// How do I replacing letters and subwords
//Replace a generator at the second position by x10
w_tmp = wl;
wI = w_tmp.begin();
w_tmp.replace( ++wI,5 );
cout << "Replace :" << wl << " -> " << w_tmp << endl;
// Replace a subword of a word starting at the second position by a word [B,E).
// The length of the word does not increase if [B,E) is longer than the terminal
// segment of the word [it,end()).
//In that case terminal symbols of [B,E) are ignored.
w_tmp = wl;
wI = w_tmp.begin();
// w_tmp.replace::const_iterator>( ++wI,wv.getList().begin(), wv.getList().end() );
// cout << "Replace :" << wl << " -> " << w_tmp << endl;
// How to generate a pseudo-random word
// Generate a pseudo randomly reduced word of the length 10 in 2 generators
cout << "Generate pseudo-random word of length 10 " << Word::randomWord( 2 , 10 ) << endl;
// Generates a pseudo randomly reduced word of a length in [10,15] and 2 generators
cout << "Generate pseudo-random word of length in [10,15] " << Word::randomWord( 2,10,15 ) << endl;