Permalink
Browse files

add example snippets. Compiled by masak++ in https://gist.github.com/…

  • Loading branch information...
1 parent aadb728 commit 6e8909f40a95d6711c6b5fa4984f44a843573480 @moritz moritz committed Aug 12, 2012
@@ -0,0 +1,12 @@
+<pre>[% syntax perl6 %]
+my @beers = 'beers', 'beer', 'beers' xx 97;
+
+for reverse(1..99) Z reverse(0..98) -> $n, $nn {
+ say "$n @beers[$n] on the wall!";
+ say "$n @beers[$n]!";
+ say "Take one down, pass it around,";
+ say "$nn @beers[$nn] on the wall!";
+}
+[% endsyntax %]</pre>
+[% option no-header %][% option no-footer %]
+
@@ -0,0 +1,16 @@
+<pre>[% syntax perl6 %]
+my $birth-date-string = prompt "When were you born (yyyy-mm-dd)?";
+my $birth-date = Date.new($birth-date-string);
+
+my $today = Date.today;
+my $age = $today.year - $birth-date.year;
+
+# But your birthday this year may not have been yet
+if $today.day-of-year < $birth-date.day-of-year {
+ $age--;
+}
+
+say "You are $age years old!";
+[% endsyntax %]</pre>
+[% option no-header %][% option no-footer %]
+
@@ -0,0 +1,11 @@
+<pre>[% syntax perl6 %]
+my @scale = ("$_$_" for 0..9, <a b c d e f>);
+my @zeroes = '00' xx 16;
+
+# Fade from red to blue
+for @scale.reverse Z @zeroes Z @scale -> $r, $g, $b {
+ say "#$r$g$b";
+}
+[% endsyntax %]</pre>
+[% option no-header %][% option no-footer %]
+
@@ -0,0 +1,9 @@
+<pre>[% syntax perl6 %]
+my $sentence = "I am going to go feed the the cat.";
+
+if $sentence ~~ / (\w+) \h+ $0 / {
+ say "Duplicate word '$0 $0' found at position $/.from().";
+}
+[% endsyntax %]</pre>
+[% option no-header %][% option no-footer %]
+
@@ -0,0 +1,8 @@
+<pre>[% syntax perl6 %]
+for 10 ... 0 -> $count {
+ say "$count...";
+ LAST { say "Liftoff!" };
+}
+[% endsyntax %]</pre>
+[% option no-header %][% option no-footer %]
+

0 comments on commit 6e8909f

Please sign in to comment.