5

I was trying to execute this program in Raku but I got an error below: How should I provide raku with the perl library there; what to copy where ?

use Math::BigInt;
$i = Math::BigInt->new($string);
use Math::BigInt ':constant';
print 10**121900;

enter image description here

Could not find Math::BigInt in

EDIT

I have failed to run zef after installing it:

enter image description here

Failed to stat file: no such file or directory

EDIT

enter image description here

Failed to stat file: no such file or directory

shaedrich
  • 5,457
  • 3
  • 26
  • 42
user2925716
  • 949
  • 1
  • 6
  • 13
  • 3
    First question: why would you want to use `Math::BigInt`? Integers in Raku are bigints by default. Just executing `print 10**121900` will give you a `1` followed by `121900` zeroes. – Elizabeth Mattijsen May 29 '21 at 20:15
  • 1
    Second question: to be able to use Perl modules from Raku, you **must** install the `Inline::Perl5` module first: `zef install Inline::Perl5`. After that, you can use modules with the `from` adverb. In your example: `use Math::BigInt:from`. – Elizabeth Mattijsen May 29 '21 at 20:17
  • 1
    Your first answer has helped, it really works. For your second comment, I use `Cygwin` which doesn't know anything like `zef`. Could you give me a link to download `InLine::Perl5` ? – user2925716 May 29 '21 at 20:20
  • 1
    Then it's probably wiser to first download `zef` (`git clone https://github.com/ugexe/zef.git` and follow the README), and then do `zef install Inline::Perl5` :-) – Elizabeth Mattijsen May 29 '21 at 21:05
  • 2
    @user2925716 What link did you visit to get Rakudo before you installed it? – raiph May 29 '21 at 21:07
  • cygwin is 1990s tech and it never worked really well. better use WSL2 which gives you a real linux kernel, not a bolted on stopgap – Holli May 30 '21 at 05:24
  • @ElizabethMattijsen I had to first install `git`. Now I have `zef` but it writes an error, please see my **EDIT**. – user2925716 May 30 '21 at 14:01
  • @ElizabethMattijsen I got **nothing** from executing `zef`: `hynek0@hynek /cygdrive/c/Users/hynek0/Desktop/FU/A3/rakudo-moar-2021.05-01-win-x86_64-msvc/share/perl6/site/bin $ ./zef install Inline::Perl5 ===> Searching for: Inline::Perl5` The program just hangs on. – user2925716 May 30 '21 at 14:10
  • Meh, I think Raku is just broken on Cygwin :-( I don't think we have a CI environment set up for it :-( – Elizabeth Mattijsen May 30 '21 at 19:17

1 Answers1

6

Math::BigInt is a Perl module

  1. Inline::Perl needs to be installed in Raku
  2. Math::BigInt needs to be installed in Perl
  3. You need to tell Raku that it is a Perl module rather than the default of being a Raku module
use Inline::Perl5;
use Math::BigInt:from<Perl5>;

my $string = "121900";
my $i = Math::BigInt->new($string);

say 10**$i;

(Untested as I am away from my computer)

Of course that is rather pointless as Raku already supports large integers.

say 10**121900;
shaedrich
  • 5,457
  • 3
  • 26
  • 42
Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129