<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">So Patrick,<br>
<br>
If I want to see your solution running, what's the best
recommended way to get a working perl6 environment these days?<br>
<br>
<div class="moz-signature">Robert Flach<br>
<b>Web Tools</b><br>
</div>
On 9/11/2014 1:32 PM, Patrick R. Michaud wrote:<br>
</div>
<blockquote cite="mid:20140911183235.GA18564@pmichaud.com"
type="cite">
<pre wrap="">Perl 6 solution #1, the straightforward one:
for 1..100 {
when $_ %% (3 & 5) { say "FizzBuzz" }
when $_ %% 5 { say "Buzz" }
when $_ %% 3 { say "Fizz" }
say $_;
}
Some explanation:
- The Perl 6 "%%" operator returns true if the left argument is evenly
divisible by the right argument.
- The "when" keyword is Perl 6's version of a "switch/case" statement;
when the test is true, the block following it is executed and control
skips to the end of the enclosing block.
- The expression "$_ %% (3 & 5)" is true if $_ is evenly divisible
by both 3 and 5. (The "&" operator in Perl 6 creates a junction
of values, the numeric bitwise-and operator in Perl 6 is "+&".)
Pm
_______________________________________________
Dfw-pm mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dfw-pm@pm.org">Dfw-pm@pm.org</a>
<a class="moz-txt-link-freetext" href="http://mail.pm.org/mailman/listinfo/dfw-pm">http://mail.pm.org/mailman/listinfo/dfw-pm</a>
</pre>
</blockquote>
<br>
</body>
</html>