We'll have more to say about these classes later but basically we have plus ("+") methods for adding
ZERO identity element and a
flatten method which takes our
Segment and converts it into a list of words.
and gives me confidence that my algorithm is a monoid. The above showed that
Segments have left and right identity elements for "+" (in fact both
Segment.ZERO work). If we wanted to, we could have additional checks for the associativity piece or for properties of
What have we achieved? Well, now we are in a position to write some parallel versions of our algorithm. Many have a common strategy and that is to divide the input into sections. Typically the division stops once the sections reach a certain granularity of size. As a general rule, if we divide past a certain level of granularity, then the overheads associated with setting up the parallelism out weigh the parallelism gains.