On 10/3/18 7:46 PM, Trey Harris wrote:
Assuming you are suggesting your examples are showing differences between the languages, in all your examples of differences between Perl 6 and Perl 5 below, you are using the wrong operator or you changed one of the arguments between the Perl 5 and Perl 6 examples.

I won't go through them each, but for example '> 3' is the greater-than operator in Perl 5; 0b0001_0100 (20) is greater than 3, so the answer is 1 (true). And in your bitwise shift left, you're shifting by 2 in Perl 6 but by 3 in Perl 5. And so on.


Hi Trey,

Ah poop!  I made another booboo.  Mumble, mumble.

corrected:
    $ p5 'my $v = 0b00000100 << 3; say $v;'
    32

This is my own reference.  I do still maintain a few p5 programs
so I was writing a one size fits all.

Thank you for the catch!

-T


My Keepers is basically a directory by subject:

    perl6.String.to.Integer.txt
    perl6.string.words.example.txt
    perl6.string.zeros.remove.leading.txt
    perl6.subroutines.passing.arrays.and.hashes.html
    perl6.subroutines.txt
    perl6.subs.calling.ones.self.txt
    perl6.subs.name.of.sub.txt
    perl6.succ.successor.txt
    perl6.syntax.check.txt
    perl6.syntax.txt

145 of them now.  They are my first line of reference when programming.

For instance: perl6.String.to.Integer.txt  (notice how I start
simple and them more up):



Perl 6: convert String to Integer and Integer to String:


String to Integer:
   $ p6 'my Str $x = "122333"; my Int $y = $x.Int; say $y;'
   122333

   $ p6 'my Int $x; my Str $y = "5"; $x = "$y" + 0; say "$x";'
   5


Integer to String:
   $ p6 'my Int $x = 122333; my Str $y = $x.Str; say $y;'
   122333

   $ p6 'my Str $x; my Int $y = 9; $x = "$y"; say "$x";'
   9

$ p6 'my Str $x = "1\n22\n333\n"; my Int @y; @y = ( split "\n", $x, :skip-empty )>>.Int; for @y -> Int $i {say $i;}'
   1
   22
   333

$ p6 'my Str $x = "1\n22\n333\n"; my Int @y; for ( split "\n", $x, :skip-empty )>>.Int -> $i {say $i;}'
   1
   22
   333


"dd":
   $ p6 'my Str $x = "5"; my Int $y = dd +$x; say $y'
   5
   (Int)

   $ p6 'my Int $y = 7; my Str $x = dd ~$y; say $x'
   "7"
   (Str)

Reply via email to