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

Problem defining factorial operator in .rakumod file

Thread Next
From:
Joseph Polanik
Date:
October 13, 2022 23:37
Subject:
Problem defining factorial operator in .rakumod file
Message ID:
d53cb986-7c53-6458-cac0-4a9a1a4b1079@charter.net
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.

Thanks,

Joe




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About