[DFW.pm] Homework for the list, and for Oct 08 meeting

John Dexter john.dexter at psydefect.com
Wed Sep 24 15:34:12 PDT 2014


Thanks, Patrick. That's cool! I have seen some examples with multisubs for
MAIN, but didn't think to use it in this case.


John Dexter

On Wed, Sep 24, 2014 at 4:48 PM, Patrick R. Michaud <pmichaud at pobox.com>
wrote:

>
> Note that MAIN can be a multisub.  In other words, you can do:
>
>   multi sub MAIN(Int :$end = 100, Int :$fizz = 3, Int :$buzz = 5)
>   {
>      ...
>   }
>
>   multi sub MAIN(Bool :$help)
>   {
>     say qq:to"END_USAGE";
>     ...
>     END_USAGE
>   }
>
>
> Perl 6 will select the MAIN() sub based on the options provided on the
> command line.
>
> Pm
>
>
> On Wed, Sep 24, 2014 at 04:19:34PM -0500, John Dexter wrote:
> > Again with some TIMTOWTDI. I'm trying to learn some Perl6 so here is my
> > FizzBuzz basketball attempt (definitely not golf anyway).
> >
> > It's a full CLI application; complete with usage screen and some tests.
> > https://github.com/PsyDefect/App-FizzBuzz.git
> >
> >
> > John Dexter
> >
> > On Fri, Sep 12, 2014 at 12:08 AM, kevin <kbrannen at pwhome.com> wrote:
> >
> > > On 09/11/2014 02:03 PM, Tommy Butler wrote:
> > > ...
> > >
> > >> http://rosettacode.org/wiki/FizzBuzz
> > >>
> > >> Is all about the modulus operator.  To do it another way might be
> > >> creative but would almost certainly likely be less efficient.  The
> only
> > >> thing I can think of that world be faster is the cheat method I saw,
> > >> where you hard code into your program the known fizzes and buzzes,
> > >> spitting them out at the corresponding integer positions in the 1 to
> 100
> > >> loop.
> > >>
> > > ...
> > >
> > > You mean in the spirit of "Sieve of Eratosthenes" where you trade
> space of
> > > complexity? That's the only way I can think of to do it without the
> modulus
> > > operator.
> > >
> > > my @nums;
> > > for ($i=3 ; $i <= 100 ; $i += 3) { $nums[$i]++; }
> > > for ($i=5 ; $i <= 100 ; $i += 5) { $nums[$i] += 2; }
> > > my @strings = (0, "Fizz", "Buzz", "FizzBuzz");
> > > print (($strings[$nums[$_]] || $_) . "\n") for (1 .. 100);
> > >
> > > I don't think I'd call that cheating, but inefficient I'll agree with.
> :)
> > >
> > > By cheating, I assume the method where you create an array with 100
> > > hard-coded values? Yeah, I go with cheating there. :)
> > >
> > > Kevin
> > > _______________________________________________
> > >
> > > Dfw-pm mailing list
> > > Dfw-pm at pm.org
> > > http://mail.pm.org/mailman/listinfo/dfw-pm
> > >
>
> > _______________________________________________
> > Dfw-pm mailing list
> > Dfw-pm at pm.org
> > http://mail.pm.org/mailman/listinfo/dfw-pm
>
> _______________________________________________
> Dfw-pm mailing list
> Dfw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/dfw-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/dfw-pm/attachments/20140924/0d2d97af/attachment.html>


More information about the Dfw-pm mailing list