shift left syntax?

Hi All,

Is this the only way to shift left?

       $i = $i +< 0x01

$ p6 'my int32 $i=0x00005DAE; 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
0
perl6
2/8/2019 6:20:14 AM
perl.perl6.users 1159 articles. 0 followers. Follow

4 Replies
35 Views

Similar Articles

[PageSpeed] 40

--000000000000f989b905815c2e14
Content-Type: text/plain; charset="UTF-8"

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

BB5C

-y


>

--000000000000f989b905815c2e14
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">perl6 -e &#39;my $i =3D =
0x00005DAE; $i +&lt;=3D 1; say $i.base(0x10);&#39;<br><br>BB5C</div><div di=
r=3D"ltr"><br><div><div dir=3D"ltr" class=3D"gmail_signature">-y<br></div><=
/div><br></div></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-=
style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
</blockquote></div></div>

--000000000000f989b905815c2e14--
0
not
2/8/2019 6:36:37 AM

On 2/7/19 10:36 PM, yary wrote:
> perl6 -e 'my $i = 0x00005DAE; $i +<= 1; say $i.base(0x10);'
> 
> BB5C
> 
> -y
> 
> 

Hi Yary,

$ p6 'my Buf $x=Buf.new(0xAE,0x5D); my int32 $i=0x00005DAE; 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<ae 5d>
5DAE
5DAE


Ah poop!  I forgot the =

$ p6 'my int32 $i=0x00005DAE; say $i.base(0x10); $i +<= 0x01; say 
$i.base(0x10);'
5DAE
BB5C


Thank you!

-T
0
perl6
2/8/2019 6:41:44 AM
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
<perl6-users@perl.org> wrote:
>
> Hi All,
>
> Is this the only way to shift left?
>
>        $i = $i +< 0x01
>
> $ p6 'my int32 $i=0x00005DAE; 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
0
b2gills
2/8/2019 6:02:39 PM
 >>
 >> Hi All,
 >>
 >> Is this the only way to shift left?
 >>
 >>         $i = $i +< 0x01
 >>
 >> $ p6 'my int32 $i=0x00005DAE; 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
> <perl6-users@perl.org> wrote:

Thank you!
0
perl6
2/8/2019 7:13:04 PM
Reply: