<div dir="ltr">Thanks, Patrick. That's cool! I have seen some examples with multisubs for MAIN, but didn't think to use it in this case.</div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>John Dexter<br></div></div>
<br><div class="gmail_quote">On Wed, Sep 24, 2014 at 4:48 PM, Patrick R. Michaud <span dir="ltr"><<a href="mailto:pmichaud@pobox.com" target="_blank">pmichaud@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Note that MAIN can be a multisub.  In other words, you can do:<br>
<br>
  multi sub MAIN(Int :$end = 100, Int :$fizz = 3, Int :$buzz = 5)<br>
  {<br>
     ...<br>
  }<br>
<br>
  multi sub MAIN(Bool :$help)<br>
  {<br>
    say qq:to"END_USAGE";<br>
    ...<br>
    END_USAGE<br>
  }<br>
<br>
<br>
Perl 6 will select the MAIN() sub based on the options provided on the command line.<br>
<span class="HOEnZb"><font color="#888888"><br>
Pm<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Wed, Sep 24, 2014 at 04:19:34PM -0500, John Dexter wrote:<br>
> Again with some TIMTOWTDI. I'm trying to learn some Perl6 so here is my<br>
> FizzBuzz basketball attempt (definitely not golf anyway).<br>
><br>
> It's a full CLI application; complete with usage screen and some tests.<br>
> <a href="https://github.com/PsyDefect/App-FizzBuzz.git" target="_blank">https://github.com/PsyDefect/App-FizzBuzz.git</a><br>
><br>
><br>
> John Dexter<br>
><br>
> On Fri, Sep 12, 2014 at 12:08 AM, kevin <<a href="mailto:kbrannen@pwhome.com">kbrannen@pwhome.com</a>> wrote:<br>
><br>
> > On 09/11/2014 02:03 PM, Tommy Butler wrote:<br>
> > ...<br>
> ><br>
> >> <a href="http://rosettacode.org/wiki/FizzBuzz" target="_blank">http://rosettacode.org/wiki/FizzBuzz</a><br>
> >><br>
> >> Is all about the modulus operator.  To do it another way might be<br>
> >> creative but would almost certainly likely be less efficient.  The only<br>
> >> thing I can think of that world be faster is the cheat method I saw,<br>
> >> where you hard code into your program the known fizzes and buzzes,<br>
> >> spitting them out at the corresponding integer positions in the 1 to 100<br>
> >> loop.<br>
> >><br>
> > ...<br>
> ><br>
> > You mean in the spirit of "Sieve of Eratosthenes" where you trade space of<br>
> > complexity? That's the only way I can think of to do it without the modulus<br>
> > operator.<br>
> ><br>
> > my @nums;<br>
> > for ($i=3 ; $i <= 100 ; $i += 3) { $nums[$i]++; }<br>
> > for ($i=5 ; $i <= 100 ; $i += 5) { $nums[$i] += 2; }<br>
> > my @strings = (0, "Fizz", "Buzz", "FizzBuzz");<br>
> > print (($strings[$nums[$_]] || $_) . "\n") for (1 .. 100);<br>
> ><br>
> > I don't think I'd call that cheating, but inefficient I'll agree with. :)<br>
> ><br>
> > By cheating, I assume the method where you create an array with 100<br>
> > hard-coded values? Yeah, I go with cheating there. :)<br>
> ><br>
> > Kevin<br>
> > _______________________________________________<br>
> ><br>
> > Dfw-pm mailing list<br>
> > <a href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a><br>
> > <a href="http://mail.pm.org/mailman/listinfo/dfw-pm" target="_blank">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br>
> ><br>
<br>
> _______________________________________________<br>
> Dfw-pm mailing list<br>
> <a href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a><br>
> <a href="http://mail.pm.org/mailman/listinfo/dfw-pm" target="_blank">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br>
<br>
_______________________________________________<br>
Dfw-pm mailing list<br>
<a href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/dfw-pm" target="_blank">http://mail.pm.org/mailman/listinfo/dfw-pm</a><br>
</div></div></blockquote></div><br></div>