run line question

2019-11-23 Thread ToddAndMargo via perl6-users

Hi All,

When folks write programs that read the run line like

   /a abc /r xyz
or
   /r xyz /a aaabc
or
  dd bs=4096 if=xxx.iso of=/dev/sdc

basically, in any order.

How do they keep track of what goes where?

Many thanks,
-T


Re: which windows am I in?

2019-11-23 Thread ToddAndMargo via perl6-users

On 2019-11-22 23:41, ToddAndMargo via perl6-users wrote:
 > Hi All,
 >
 > In Perl6 for Windows, how do I tell if I am
 > in Windows 7 or 10?
 >
 > Many thanks,
 > -T

What I have so far:

Windows 6.  I am not even going to ask...


Windows version:

Windows 10:

C:\>ver
Microsoft Windows [Version 10.0.18363.476]

perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver
~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"
10



Windows 7:

C:\>ver
Microsoft Windows [Version 6.1.7601]

perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver
~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"
6



On 2019-11-23 10:22, Brad Gilbert wrote:

Windows before Windows 10 had different internal and external numbers.

https://www.gaijin.at/en/infos/windows-version-numbers



Hi Brad,

H.  Sounds like a table of hashes in the making.

Thank you!

-T


Re: for by 3?

2019-11-23 Thread ToddAndMargo via perl6-users

On 2019-11-23 04:19, Elizabeth Mattijsen wrote:

for lines.rotor(3) -> ($,$,$third) { dd $third }


$ p6 ' my @x=; for @x.rotor(3) -> ($,$,$third) { dd 
$third };'

"c"
"F"
"j"


Re: for by 3?

2019-11-23 Thread ToddAndMargo via perl6-users
On Sat, 23 Nov 2019 at 07:00, ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


Hi All,

In a "for" loop, what is the syntax for "by 3"?

  for @x.lines by 3

In other words, every third line.

Many thanks,
-T



On 2019-11-23 03:30, Raymond Dresens wrote:

Hello,

This seems possible:

     > my @x = (1, 2, 3, 4, 8, 16, 32, 64, 128);
     [1 2 3 4 8 16 32 64 128]

Then:

     > for @x -> $x, $y, $z { $x.say }
     1
     4
     32

And:

     > for @x -> $x, Any, Any { $x.say }
     1
     4
     32

...assigning to 'Any' seems to 'just work'. Assigning to 'Nil' didn't 
work, however.


Is this what you are looking for?

Perhaps there's a better way for doing this? If so, I'd like to know too :)

Regards,

Raymond.



Hi Raymond,

Sweet.  And I have access to the other lines if I want.

$ p6 ' my @x=; for @x -> $L1, $L2, $L3 { say "L1 = 
$L1\nL2 = $L2\nL3 = $L3\n" };'


L1 = a
L2 = b
L3 = c

L1 = D
L2 = E
L3 = F

L1 = h
L2 = i
L3 = j

Thank you!
-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: for by 3?

2019-11-23 Thread ToddAndMargo via perl6-users

On 2019-11-23 04:19, Elizabeth Mattijsen wrote:

for lines.rotor(3) -> ($,$,$third) { dd $third }


Thank you!


Re: which windows am I in?

2019-11-23 Thread Brad Gilbert
Windows before Windows 10 had different internal and external numbers.

https://www.gaijin.at/en/infos/windows-version-numbers

On Sat, Nov 23, 2019, 2:03 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2019-11-22 23:41, ToddAndMargo via perl6-users wrote:
> > Hi All,
> >
> > In Perl6 for Windows, how do I tell if I am
> > in Windows 7 or 10?
> >
> > Many thanks,
> > -T
>
> What I have so far:
>
> Windows 6.  I am not even going to ask...
>
>
> Windows version:
>
> Windows 10:
>
> C:\>ver
> Microsoft Windows [Version 10.0.18363.476]
>
> perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver
> ~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"
> 10
>
>
>
> Windows 7:
>
> C:\>ver
> Microsoft Windows [Version 6.1.7601]
>
> perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver
> ~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"
> 6
>


Re: comment: Perl6 vs batch

2019-11-23 Thread Veesh Goldman
There are other indications that Windows was designed by the devil, like
the line ending format and the fact that they use UTF-16LE instead of UTF-8
in excel. Who the heck uses utf16!

On Sat, Nov 23, 2019 at 10:12 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> I broke down and installed Perl6 on my two Windows Virtual
> Machine: w7 and w-Nein (w10).
>
> OH HOLY MOLLY it is easier to program in Perl6 than batch!!!
> I think batch may have been designed by the devil himself!
> Okay, maybe not, but
>
> I feel stupid I did not do it years ago!
>
> -T
>


Re: for by 3?

2019-11-23 Thread Elizabeth Mattijsen
for lines.rotor(3) -> ($,$,$third) { dd $third }

> On 23 Nov 2019, at 13:06, ToddAndMargo via perl6-users  
> wrote:
> 
> On 2019-11-23 03:35, Elizabeth Mattijsen wrote:
>> If you don't want any results with less than 3 lines:
>> for lines.rotor(3) -> @a {
>>dd @a;
>> }
>> If you *do* want results with 3 lines:
>> for lines.rotor(3, :partial) -> @a {
>> dd @a;
>> }
>> Alternately as shown below:
>> for lines -> $x, $y?, $z? {
>> dd $x, $y, $z
>> }
>> Note the question marks to make $y and $z optional: otherwise the last 
>> iteration will throw an exception if there were less than 3 lines left.
> 
> I only want to see every third line.
> 
> loop (my $I=0; $I < @Result.elems; $I+=3) { say "@Result[$I]";}
> 
> but with a "for" loop, not a "C" loop.


Re: for by 3?

2019-11-23 Thread ToddAndMargo via perl6-users

On 2019-11-23 03:35, Elizabeth Mattijsen wrote:

If you don't want any results with less than 3 lines:

 for lines.rotor(3) -> @a {
dd @a;
 }

If you *do* want results with 3 lines:

 for lines.rotor(3, :partial) -> @a {
 dd @a;
 }

Alternately as shown below:

 for lines -> $x, $y?, $z? {
 dd $x, $y, $z
 }

Note the question marks to make $y and $z optional: otherwise the last 
iteration will throw an exception if there were less than 3 lines left.



I only want to see every third line.

loop (my $I=0; $I < @Result.elems; $I+=3) { say "@Result[$I]";}

but with a "for" loop, not a "C" loop.


Re: for by 3?

2019-11-23 Thread Elizabeth Mattijsen
Ah, yes, .rotor may be overkill for this.  .batch(3) will do fine as well  :-)

> On 23 Nov 2019, at 12:34, Simon Proctor  wrote:
> 
> If you want to read you lines in groups of 3 then you want batch :
> 
> for @x.lines.batch(3) -> @b 
> 
> If you just want the third line and throw away the first I'd probably do a 
> tail on that.
> 
> for @x.lines.batch(3).map( *.tail ) -> $l
> 
> Note you need to map the tail on each batch of three not slap it on the end.
> 
> 
> On Sat, 23 Nov 2019, 06:00 ToddAndMargo via perl6-users, 
>  wrote:
> Hi All,
> 
> In a "for" loop, what is the syntax for "by 3"?
> 
>  for @x.lines by 3
> 
> In other words, every third line.
> 
> Many thanks,
> -T


Re: for by 3?

2019-11-23 Thread Elizabeth Mattijsen
If you don't want any results with less than 3 lines:

for lines.rotor(3) -> @a {
   dd @a;
}

If you *do* want results with 3 lines:

for lines.rotor(3, :partial) -> @a {
dd @a;
}

Alternately as shown below:

for lines -> $x, $y?, $z? {
dd $x, $y, $z
}

Note the question marks to make $y and $z optional: otherwise the last 
iteration will throw an exception if there were less than 3 lines left.


> On 23 Nov 2019, at 12:30, Raymond Dresens  wrote:
> 
> Hello,
> 
> This seems possible:
> 
> > my @x = (1, 2, 3, 4, 8, 16, 32, 64, 128);
> [1 2 3 4 8 16 32 64 128]
> 
> Then:
> 
> > for @x -> $x, $y, $z { $x.say }
> 1
> 4
> 32
> 
> And:
> 
> > for @x -> $x, Any, Any { $x.say }
> 1
> 4
> 32
> 
> ...assigning to 'Any' seems to 'just work'. Assigning to 'Nil' didn't work, 
> however.
> 
> Is this what you are looking for?
> 
> Perhaps there's a better way for doing this? If so, I'd like to know too :)
> 
> Regards,
> 
> Raymond.
> 
> On Sat, 23 Nov 2019 at 07:00, ToddAndMargo via perl6-users 
>  wrote:
> Hi All,
> 
> In a "for" loop, what is the syntax for "by 3"?
> 
>  for @x.lines by 3
> 
> In other words, every third line.
> 
> Many thanks,
> -T


Re: for by 3?

2019-11-23 Thread Simon Proctor
If you want to read you lines in groups of 3 then you want batch :

for @x.lines.batch(3) -> @b

If you just want the third line and throw away the first I'd probably do a
tail on that.

for @x.lines.batch(3).map( *.tail ) -> $l

Note you need to map the tail on each batch of three not slap it on the end.


On Sat, 23 Nov 2019, 06:00 ToddAndMargo via perl6-users, <
perl6-us...@perl.org> wrote:

> Hi All,
>
> In a "for" loop, what is the syntax for "by 3"?
>
>  for @x.lines by 3
>
> In other words, every third line.
>
> Many thanks,
> -T
>


Re: for by 3?

2019-11-23 Thread Raymond Dresens
Hello,

This seems possible:

> my @x = (1, 2, 3, 4, 8, 16, 32, 64, 128);
[1 2 3 4 8 16 32 64 128]

Then:

> for @x -> $x, $y, $z { $x.say }
1
4
32

And:

> for @x -> $x, Any, Any { $x.say }
1
4
32

...assigning to 'Any' seems to 'just work'. Assigning to 'Nil' didn't work,
however.

Is this what you are looking for?

Perhaps there's a better way for doing this? If so, I'd like to know too :)

Regards,

Raymond.

On Sat, 23 Nov 2019 at 07:00, ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> In a "for" loop, what is the syntax for "by 3"?
>
>  for @x.lines by 3
>
> In other words, every third line.
>
> Many thanks,
> -T
>


comment: Perl6 vs batch

2019-11-23 Thread ToddAndMargo via perl6-users

Hi All,

I broke down and installed Perl6 on my two Windows Virtual
Machine: w7 and w-Nein (w10).

OH HOLY MOLLY it is easier to program in Perl6 than batch!!!
I think batch may have been designed by the devil himself!
Okay, maybe not, but

I feel stupid I did not do it years ago!

-T


Re: which windows am I in?

2019-11-23 Thread ToddAndMargo via perl6-users

On 2019-11-22 23:41, ToddAndMargo via perl6-users wrote:

Hi All,

In Perl6 for Windows, how do I tell if I am
in Windows 7 or 10?

Many thanks,
-T


What I have so far:

Windows 6.  I am not even going to ask...


Windows version:

Windows 10:

C:\>ver
Microsoft Windows [Version 10.0.18363.476]

perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver 
~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"

10



Windows 7:

C:\>ver
Microsoft Windows [Version 6.1.7601]

perl6 -e "my $Rtn = qx ( ver ); my $Ver = $Rtn.lines[1].words[3]; $Ver 
~~ s/ \] //; $Ver ~~ s/ \. .* //; say $Ver;"

6