On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users
<perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
Hi All,
I am looking for an easier way to load a buffer.
I know about this way
[4] > my Buf $b=Buf.new(0x2A, 0x54, 0xFF, 0x53);
Buf:0x<2A 54 FF 53>
I would like to do it on one big blast:
my Buf $b=Buf.new(0x2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78);
Cannot unbox 170 bit wide bigint into native integer
But do not know the proper syntax.
Any words of wisdom? Am I stuck with the hard way?
Many thanks,
-T
On 6/10/22 08:36, Simon Proctor wrote:
So Buf is expecting a list of integers. If' you've got one long one in a
string like "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78" you want to
split it into smaller values so something like this?
my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
Which does the trick I think.
[0] > my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78
[1] > my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
===SORRY!=== Error while compiling:
Calling comb(Int) will never work with signature of the proto ($, $, $?, *%)
------> my Buf $b=Buf.new(⏏comb(2).map( *.parse-base(16) ));
[1] >
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~