11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

140 • Chapter 3: <strong>Programming</strong> with Modules> end do;> rep_pos := rep_pos + prev_ord;> if rep_pos > ord then> break> end if> end do> end if> end do;> Entries( elements )> end proc:The coding of this algorithm is generic. The exported members of thegroup object G are used to effect computations within the procedure.Even comparisons of equality use the export eq instead of the built-incomparison operator ‘=‘. (The need for this is illustrated below.)Using the Symmetric constructor previously defined, you can computethe elements of the symmetric group S 4 , using Dimino’s algorithm, asfollows.> G := Symmetric( 4 );G := module()exportid , ‘.‘, mul , inv, eq, member, gens, order, elements;option record ;end module> Dimino( G );{[2, 1, 3, 4], [2, 3, 1, 4], [1, 2, 3, 4], [3, 2, 1, 4],[2, 3, 4, 1], [3, 2, 4, 1], [1, 3, 4, 2], [3, 1, 4, 2],[3, 4, 1, 2], [4, 3, 1, 2], [2, 4, 1, 3], [4, 2, 1, 3],[3, 4, 2, 1], [4, 3, 2, 1], [4, 1, 2, 3], [1, 4, 2, 3],[3, 1, 2, 4], [1, 3, 2, 4], [4, 1, 3, 2], [1, 4, 3, 2],[4, 2, 3, 1], [2, 4, 3, 1], [1, 2, 4, 3], [2, 1, 4, 3]}Anticipating later developments, the procedure Dimino has beencoded to accept a second, optional argument that specifies an alternateset of generators to use. Thus, you could compute the same set using theset {(12), (23), . . . , (n − 1, n)} of transpositions instead.> Dimino( G, { [2,1,3,4], [1,3,2,4], [1,2,4,3] } );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!