1 # plays with some fun operator overloading.
3 # Please remember to update t/examples/examples.t and rename
4 # examples/output/overloading if you rename/move this file.
8 multi postfix
:<!> ($x) { [*] 1..$x }
9 multi postfix
:<!> (@x) { [*] @x }
11 multi infix
:<z
> (@x, @y) { each(@x;@y) }
12 multi infix
:<z
> (Str
$x, Str
$y) { $x ~ $y }
18 my $test = "hello" z
"goodbye";
21 $test = 10!; $test.perl
.say;
27 multi
sub postfix
:<%> ($_) { $_ / 100 }
28 multi
sub infix
:<of
> ($x,$y) {$x * $y}
31 sub base
(Int
$M, Int
$N) {
32 return $M if ($M < $N);
34 return base
(int($M/$N),$N) ~ $t;
37 multi
sub infix
:<base
> ($x,$y) {base
($x,$y)}
38 say $_ base
2 for (1..5);
40 # Commented so this file can be used in example.t.
41 # multi sub infix:<<.?.>> ($low,$high) { int( ($high - $low).rand + $low ) + 1; };