RCRPG/Raku: Difference between revisions

m
→‎RCRPG/Raku: Fix syntax highlighting
m (→‎{{header|Perl 6}}: a few minor tweaks and bug fixs)
m (→‎RCRPG/Raku: Fix syntax highlighting)
 
(5 intermediate revisions by the same user not shown)
Line 1:
{{collection|RCRPG}}
=={{example|task=RCRPG|language=Raku}}==
 
This [[Perl 6Raku]] version of [[RCRPG]] implements a text interface.
 
==Language Idioms==
This version of RCRPG demonstrates the following idioms in Perl 6Raku.
* A simple [[input loop]]
* Subroutines (Functions)
Line 23:
As with the [[RCRPG/Perl|Perl version]].
==Code==
{{works with|nieczaRakudo|v242018.03}}
<syntaxhighlight lang="raku" perl6line>my %commands;
{{works with|Rakudo|2013.05}}
<lang perl6>my %commands;
my %rooms;
 
Line 41 ⟶ 40:
up => 'in the ceiling',
down => 'in the floor',
(map { ($_ => "to the $_") }, <north south east west>).Slip;
 
my %dir_vec =
Line 51 ⟶ 50:
west => [-1, 0, 0];
 
my %dir_rev = map { ($^a => $^b), $^b => $^a).Slip },
< north south east west up down >;
 
Line 68 ⟶ 67:
} else {
say "There are exits: {@$.links.join(', ')\
.subst(/','(<-[,]>+)$/, -> $/ {" and$0"})}.";
}
if $.stuff {
Line 117 ⟶ 116:
}
 
for flat <north south east west up down> -> $dir {
command [$dir, substr($dir,0,1)], '', 0, { move($dir) };
}
Line 236 ⟶ 235:
}
%rooms{$room}.greet;
}</syntaxhighlight >
}</lang>
10,333

edits