develooper Front page | perl.perl6.users | Postings from October 2022

Problem defining factorial operator in .rakumod file

Thread Next
Joseph Polanik
October 13, 2022 23:37
Problem defining factorial operator in .rakumod file
Message ID:
I am trying to define '!' as the factorial operator. The following works 
in a .raku script file:

   sub postfix:<!> ($n) is export {
     when $n == 0 {return 1}
     default {$n * ($n - 1)!}

However when I tried to move this sub to a .rakumod file, it produces an 
error: Negation metaoperator not followed by valid infix.

It turns out that this is a known issue, #3774,  with rakudo first 
logged (AFAIK) in July 2020. Until this is fixed in some future release 
of Rakudo, is there a workaround for this?

Note: I am using Rakudo v2022.07 on Ubuntu 20.04.5.



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About