3 use Test::More tests => 13;
5 use warnings FATAL => 'all';
8 use Function::Parameters {
10 check_argument_count => 1,
14 fun filter($f = fun ($x) { 1 }, @xs) {
17 : (($f->($xs[0]) ? $xs[0] : ()), filter $f, @xs[1 .. $#xs])
20 is_deeply [filter], [];
21 is_deeply [filter fun { 1 }, 2 .. 3], [2 .. 3];
22 is_deeply [filter fun ($x) { $x % 2 }, 1 .. 10], [1, 3, 5, 7, 9];
24 fun fact($k, $n) :(&$) {
27 : fact { $k->($n * $_[0]) } $n - 1
30 is +(fact { "~@_~" } 5), "~120~";
31 is +(fact { $_[0] / 2 } 6), 360;
33 fun write_to($ref) :(\$) :lvalue { $$ref }
46 fun horf_dorf($ref, $val = $c++) :(\@;$) :lvalue {
54 is_deeply \@asdf, ["A"];
55 horf_dorf(@asdf) = "b";
56 is_deeply \@asdf, ["A", "b"];
58 is_deeply \@asdf, ["A", "b", 2];
60 is_deeply \@asdf, ["A", "b", 2, 100];
62 horf_dorf(@asdf) *= 3;
63 is_deeply \@asdf, ["A", 2, 100, 6];