Re: Easier way to load a buffer?

2022-06-13 Thread Andy Bach
> You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
> And then maybe realize that Simon forgot that the comb(2) should be a method 
> on $hex?  Otherwise, how would it know what to parse?

Ah, I did wonder why $hex wasn't in the 2nd line in any way.
> my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78
> my Buf $b=Buf.new($hex.comb(2).map( *.parse-base(16) ));
Buf:0x<2A 54 FF 53 A5 F1 D3 6F 1C EA 7E 61 FC 37 A2 0D 54 A7 7F E7 B7 08>

So, take $hex 2 at a time and run that through the parse-base(16), assigning it 
to $buf

From: Elizabeth Mattijsen 
Sent: Friday, June 10, 2022 5:28 PM
To: ToddAndMargo via perl6-users 
Subject: Re: Easier way to load a buffer?

CAUTION - EXTERNAL:


> On 10 Jun 2022, at 23:28, ToddAndMargo via perl6-users  
> wrote:
>
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-users@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] >

You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
And then maybe realize that Simon forgot that the comb(2) should be a method on 
$hex?  Otherwise, how would it know what to parse?

I know it is hard to think when you're in a hurry.  But you should really learn 
to be able to read code, instead of copying examples only and not understanding 
*how* they work.
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exercise 
caution when opening attachments or clicking on links.



Re: Easier way to load a buffer?

2022-06-11 Thread ToddAndMargo via perl6-users

On 6/10/22 07:49, ToddAndMargo via perl6-users 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




Came up with a Raku way of doing what I want.
And dropping the need for Buf at the same time:


> use BigRoot;
> BigRoot.precision = 40;
40

> my $root5 = BigRoot.newton's-sqrt: 5;
> $y = sprintf  $root5.base(16)
2.3C6EF372FE94F82BE73980C0B9DB90681F

> $y ~~ s/ $( Q[.] ) //;
「.」

> say $y
23C6EF372FE94F82BE73980C0B9DB90681F

Add a loop and and some chr's and ord's and
happy camping will proceed!

:-)

-T


Re: Easier way to load a buffer?

2022-06-10 Thread Elizabeth Mattijsen



> On 10 Jun 2022, at 23:28, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-users@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] >

You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
And then maybe realize that Simon forgot that the comb(2) should be a method on 
$hex?  Otherwise, how would it know what to parse?

I know it is hard to think when you're in a hurry.  But you should really learn 
to be able to read code, instead of copying examples only and not understanding 
*how* they work.

Re: Easier way to load a buffer?

2022-06-10 Thread ToddAndMargo via perl6-users
On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
mailto:perl6-users@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
~~


Re: Easier way to load a buffer?

2022-06-10 Thread Elizabeth Mattijsen



> On 10 Jun 2022, at 22:47, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-users@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.
> 
> What does the * i *.parse-base do?

*.parse-base(16) is an example of a WhateverCode object.

It is basically syntactic sugar for easy creation of Callable blocks.  In this 
case,
it created  -> $_ { .parse-base(16) }

The * is interpreted in the Raku Grammar as a sign to create a WhateverCode 
object: it basically
represents the $_ in the signature of the created Block, and of course the $_ 
inside that block.:

Re: Easier way to load a buffer?

2022-06-10 Thread ToddAndMargo via perl6-users
On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
mailto:perl6-users@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.


What does the * i *.parse-base do?


Re: Easier way to load a buffer?

2022-06-10 Thread Simon Proctor
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.

On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users <
perl6-users@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
>


-- 
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


Easier way to load a buffer?

2022-06-10 Thread ToddAndMargo via perl6-users

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