> -----Original Message-----
> From: David Wheeler [mailto:[EMAIL PROTECTED]
>
> On Apr 16, 2004, at 7:19 AM, Simon Cozens wrote:
>
> > I'll bet you the actual most *common* use of modulus is:
> >
> > until ( my ($percent_done=done()) == 100 ) {
> > do_work();
> > print $percent_done,"\n" unless $percent_done % 10;
> > }
>
> And I'll bet it's something like this:
>
> for my $i (0..$#thingies) {
> my $css_class = $i % 2 ? 'blue' : 'yellow';
> print "<tr class="$css_class"><td>$thingies[$i]</td></tr>\n";
> }
>
> Pretty useful, actually.
>
But any real Jolt-swilling, bit-banging 'C' coder would write:
for (i = 0; i < num_thingies; ++i) {
fprintf(ostr, "<tr class=\"%s\"><td>%s</td></tr>\n",
(i & 1 ? "blue" : "yellow"),
thingies[i]);
}
:-)
(The COBOL & PL/1 guys, who use the operators just like they're supposed to
be used, would need % because they are used to three-color bar paper,
anyway. But they should be happy with "mod" anyway, for obvious reasons.)
=Austin