#!/usr/bin/perl
use Inline Pugs => '
sub postfix:<!> { [*] 1..$_ }
sub sum_factorial { [+] 0..$_! }
';
print sum_factorial(3); # 21
The implementation is in lib/Inline/Pugs.pm that comes with Pugs tree.
You'll need Inline.pm from CPAN to run the example above.
Patches, suggestions, etc welcome. :-)
Enjoy,
/Autrijus/
*evil grin*
An five-minute hack of mine proved fruitful. This is Perl 5 script,
calling into Perl 6 functions defined inline:
#!/usr/bin/perl
use pugs;
sub postfix:<!> { [*] 1..$_ }
sub sum_factorial { [+] 0..$_! }
no pugs;
print sum_factorial(3); # 21
The implementation is in lib/pugs.pm that comes with Pugs tree.
You'll need Inline.pm from CPAN to run the example above.
Patches, suggestions, etc welcome. :-)
Enjoy,
/ingy/