Re: shift left syntax?

2019-02-08 Thread ToddAndMargo via perl6-users

>>
>> Hi All,
>>
>> Is this the only way to shift left?
>>
>> $i = $i +< 0x01
>>
>> $ p6 'my int32 $i=0x5DAE; say $i.base(0x10); $i = $i +< 0x01; say
>> $i.base(0x10);'
>>
>> 5DAE
>> BB5C
>>
>>
>> Does we have any of those fancy += ~= ways of doing it?
>>
>> Many thanks,
>> -T

On 2/8/19 10:02 AM, Brad Gilbert wrote:

The `=` infix operator is a meta operator.

That means it takes an infix operator as a sort of "argument".

There is no `+=` operator, it is just the `=` operator combined with
the `+` operator.

 $a += 2;
 $a [+]= 2; # more explicitly take the + operator as an argument to
the = operator

So if you want to know how to use a similar operator to `+=`, start
with the infix operator you want, and add `=`

 $i = $i +< 0x01;

 $i [+<]= 0x01;
 $i +<= 0x01;

On Fri, Feb 8, 2019 at 12:20 AM Todd Chester via perl6-users
 wrote:


Thank you!


Re: shift left syntax?

2019-02-08 Thread Brad Gilbert
The `=` infix operator is a meta operator.

That means it takes an infix operator as a sort of "argument".

There is no `+=` operator, it is just the `=` operator combined with
the `+` operator.

$a += 2;
$a [+]= 2; # more explicitly take the + operator as an argument to
the = operator

So if you want to know how to use a similar operator to `+=`, start
with the infix operator you want, and add `=`

$i = $i +< 0x01;

$i [+<]= 0x01;
$i +<= 0x01;

On Fri, Feb 8, 2019 at 12:20 AM Todd Chester via perl6-users
 wrote:
>
> Hi All,
>
> Is this the only way to shift left?
>
>$i = $i +< 0x01
>
> $ p6 'my int32 $i=0x5DAE; say $i.base(0x10); $i = $i +< 0x01; say
> $i.base(0x10);'
>
> 5DAE
> BB5C
>
>
> Does we have any of those fancy += ~= ways of doing it?
>
> Many thanks,
> -T


Re: shift left syntax?

2019-02-07 Thread Todd Chester via perl6-users




On 2/7/19 10:36 PM, yary wrote:

perl6 -e 'my $i = 0x5DAE; $i +<= 1; say $i.base(0x10);'

BB5C

-y




Hi Yary,

$ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int32 $i=0x5DAE; say $x; say 
$i.base(0x10); $i +< 0x01; say $i.base(0x10);'


WARNINGS for -e:
Useless use of "+<" in expression "$i +< 0x01" in sink context (line 1)
Buf:0x
5DAE
5DAE


Ah poop!  I forgot the =

$ p6 'my int32 $i=0x5DAE; say $i.base(0x10); $i +<= 0x01; say 
$i.base(0x10);'

5DAE
BB5C


Thank you!

-T


Re: shift left syntax?

2019-02-07 Thread yary
perl6 -e 'my $i = 0x5DAE; $i +<= 1; say $i.base(0x10);'

BB5C

-y


>


shift left syntax?

2019-02-07 Thread Todd Chester via perl6-users

Hi All,

Is this the only way to shift left?

  $i = $i +< 0x01

$ p6 'my int32 $i=0x5DAE; say $i.base(0x10); $i = $i +< 0x01; say 
$i.base(0x10);'


5DAE
BB5C


Does we have any of those fancy += ~= ways of doing it?

Many thanks,
-T