If I have the following program in raku it works well:
trabajando-en-piensa-en-raku on ī master [?] via š v2.6.5
āÆ cat factorial.raku
sub factorial( $n ) {
[*] 1 .. $n;
}
sub postfix:<!>( $n ) {
[*] 1 .. $n;
}
my $n = 5;
say "El factorial de $n es {factorial $n}";
say "Si calculamos $n! obtenemos {$n!}";
trabajando-en-piensa-en-raku on ī master [?] via š v2.6.5
āÆ raku factorial.raku
El factorial de 5 es 120
si calculamos 5! obtenemos 120
But if I define this functions in the raku REPL I get:
> * * &factorial
> 5
> El factorial de 5 es 120
It works normally and as expected for the factorial function, but I get this for the ! operator:
> * * &postfix:<!>
> ===SORRY!=== Error while compiling:
Negation metaoperator not followed by valid infix
------> say "Si calculamos $n! obtenemos {$n!ā}";
expecting any of:
infix
infix stopper
I need an special sintax in order to define operators in raku REPL, or is depending how the environment is loaded.
I'm using In OSX Catalina
trabajando-en-piensa-en-raku on ī master [?] via š v2.6.5
āÆ rakubrew versions
system
moar-2020.07
* moar-2020.08.2
I'm afraid the REPL in its current state, has several deficiencies regarding several Raku features, such as native variables and operator definition, IF these are executed in more than one line.
Currently the REPL is basically executing an EVAL
statement for each line, with not enough information shared between invocations. This will not change in the short run. It might get better when the rakuast branch lands, sometime next year.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With