Re: print particular lines question

2020-09-02 Thread Andy Bach
AA d2: 1 AB d2: 2 ... By Geoffrey, I think I almost have it! Thanks! From: yary Sent: Tuesday, September 1, 2020 6:16 PM To: Andy Bach Cc: William Michels ; perl6-users Subject: Re: print particular lines question Every time $ shows up, it is a differe

Re: print particular lines question

2020-09-01 Thread yary
context. > Methods .^name, .raku, .gist, or .say can be used to stringify it to > something meaningful. > in block at -e line 1 > ... > AA > > but the named doesn't > raku -e 'for -> $alpha { for (1..14) { state $sv = $alpha; say > $sv; $sv++; printf("d: %

Re: print particular lines question

2020-09-01 Thread Andy Bach
ine 1 ... AA but the named doesn't raku -e 'for -> $alpha { for (1..14) { state $sv = $alpha; say $sv; $sv++; printf("d: %s\n", $sv ) } }' AA d: AB AB d: AC ____ From: William Michels Sent: Tuesday, September 1, 2020 5:30 PM To: Andy Bach Cc: y

Re: print particular lines question

2020-09-01 Thread William Michels via perl6-users
ot;, $.raku ) } }' > ===SORRY!=== Error while compiling -e > Variable $.raku used where no 'self' is available > at -e:1 > --> v = $alpha)++; printf("d: %s\n", $.raku⏏ ) } } > expecting any of: > term > > So I'm missing something about "$", I think > > > &g

Re: print particular lines question

2020-09-01 Thread Andy Bach
m So I'm missing something about "$", I think ________ From: William Michels via perl6-users Sent: Tuesday, September 1, 2020 3:17 PM To: yary Cc: perl6-users Subject: Re: print particular lines question I tried combining Larry's code and Yary's c

Re: print particular lines question

2020-09-01 Thread yary
Yes, because INIT and BEGIN happen before runtime, and $alpha is set at runtime! Hence my original BEGIN example using a constant to set the first value. Another reason to prefer "state" over those phasers... unless you want a counter over the lifetime of the process, which is valid. -y On

Re: print particular lines question

2020-09-01 Thread William Michels via perl6-users
I tried combining Larry's code and Yary's code, variously using "state" or "INIT" or "BEGIN". This is what I saw: ~$ raku -e 'for -> $alpha { for (1..14) { print (state $ = $alpha)++ ~ " " } }' AA AB AC AD AE AF AG AH AI AJ AK AL AM AN NN NO NP NQ NR NS NT NU NV NW NX NY NZ OA ~$ raku -e 'for

Re: print particular lines question

2020-09-01 Thread yary
Thanks, that's cool, and shows me something I was wondering about On Tue, Sep 1, 2020 at 11:36 AM Larry Wall wrote: > If you want to re-initialize a state variable, it's probably better to make > it explicit with the state declarator: > > $ raku -e "for { for (1..2) { say (state $ =

Re: print particular lines question

2020-09-01 Thread Larry Wall
On Mon, Aug 31, 2020 at 05:05:53PM -0700, yary wrote: : I like this better for alpha counter : : raku -e "for (1..4) { say (BEGIN $ = 'AAA')++ }" : : with BEGIN, the assignment of AAA happens once. With the earlier ||= it : checks each time through the loop. : -y Careful with that, though,

Re: print particular lines question

2020-08-31 Thread yary
Nope $_ is the "default topic" if you want to use the jargon. It has a name, the underscore character. $ is a nameless variable, jargon is "anonymous scalar" $_ is different specialness from $ -y On Mon, Aug 31, 2020 at 5:13 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-31 17:03, yary wrote: anonymous variable Would be safe thinking it had the same properties as `$_`?

Re: print particular lines question

2020-08-31 Thread yary
I like this better for alpha counter raku -e "for (1..4) { say (BEGIN $ = 'AAA')++ }" with BEGIN, the assignment of AAA happens once. With the earlier ||= it checks each time through the loop. -y On Mon, Aug 31, 2020 at 5:03 PM yary wrote: > Not even a reset- every time there's a $ by itself

Re: print particular lines question

2020-08-31 Thread Aureliano Guedes
Depends where in your code the $++ is. It may play as global or as local. raku -e 'for 1..3 {say $++}; say $++' On Mon, Aug 31, 2020 at 9:03 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > > > adn > > fixed > -- Aureliano Guedes skype: aureliano.guedes contato: (11)

Re: print particular lines question

2020-08-31 Thread yary
Not even a reset- every time there's a $ by itself it is a new/different anonymous variable. So it is only useful where it is never referred to anywhere else. $ raku -e "for (1..4) { say $++, ' , ', ++$; say 'again- ',$;}" 0 , 1 again- (Any) 1 , 2 again- (Any) 2 , 3 again- (Any) 3 , 4

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
adn fixed

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-31 16:57, ToddAndMargo via perl6-users wrote: On 2020-08-31 16:53, ToddAndMargo via perl6-users wrote: On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote:     On 2020-08-31 05:53, Brian Duggan wrote: > On Monday, August 24, Curt

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-31 16:53, ToddAndMargo via perl6-users wrote: On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote:     On 2020-08-31 05:53, Brian Duggan wrote: > On Monday, August 24, Curt Tilmes wrote: >> $ cat Lines.txt | raku -e '.say for

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2020-08-31 05:53, Brian Duggan wrote: > On Monday, August 24, Curt Tilmes wrote: >> $ cat Lines.txt | raku -e '.say for lines()[3,2,5]' > > The -n flag is an option here

Re: print particular lines question

2020-08-31 Thread yary
Answering my own question, the operator sets the type of $. That's what gradual typing is all about! $ seq 5 | raku -ne "say $++" 0 1 2 3 4 $ seq 5 | raku -ne "say $ ~= 'Hi' " Hi HiHi HiHiHi HiHiHiHi HiHiHiHiHi $ seq 5 | raku -ne "say $++, $ ~= ' Hi' " 0 Hi 1 Hi Hi 2 Hi Hi Hi 3 Hi

Re: print particular lines question

2020-08-31 Thread Aureliano Guedes
Basically : $ raku -e 'my $a = 1; say ++$a; say $a' 2 2 $ raku -e 'my $a = 1; say $a++; say $a' 1 2 On Mon, Aug 31, 2020 at 8:36 PM yary wrote: > $ by itself is an anonymous variable, putting ++ after starts it at 0 (hmm > or nil?) and increments up. > > By putting the plus plus first, ++$, it

Re: print particular lines question

2020-08-31 Thread yary
$ by itself is an anonymous variable, putting ++ after starts it at 0 (hmm or nil?) and increments up. By putting the plus plus first, ++$, it will start at 1, thanks to pre-increment versus post increment On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote:

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-31 05:53, Brian Duggan wrote: On Monday, August 24, Curt Tilmes wrote: $ cat Lines.txt | raku -e '.say for lines()[3,2,5]' The -n flag is an option here too: raku -ne '.say if $++ == 3|2|5' Lines.txt Brian Hi Bill, Works beatifically! And no bash pipe! $ raku -ne '.say

Re: print particular lines question

2020-08-31 Thread Andy Bach
rom: William Michels Sent: Monday, August 31, 2020 10:28 AM To: Brian Duggan Cc: Andy Bach ; perl6-users Subject: Re: print particular lines question How would P5 handle line numbers > 10 ? Not getting back line #11 with the P5 examples below: $ raku -ne '.say if ++$ == 3|2|5|11' test_lin

Re: print particular lines question

2020-08-31 Thread William Michels via perl6-users
Thanks Yary! So that means Brian's answer in Raku can use the smartmatch operator instead of the "==". Good to know! ~$ raku -ne '.say if ++$ ~~ 3|5|11' test_lines.txt Line 3 Line 5 Line 11 On Mon, Aug 31, 2020 at 8:47 AM yary wrote: > > Aww don't you remember Raku's earliest(?) contribution to

Re: print particular lines question

2020-08-31 Thread yary
Aww don't you remember Raku's earliest(?) contribution to Perl? I was so happy when this arrived, and sad over its subsequent neglect perl -ne 'no warnings "experimental"; print if $. ~~ [3,5,11]' line0-10.txt -y On Mon, Aug 31, 2020 at 8:28 AM William Michels via perl6-users <

Re: print particular lines question

2020-08-31 Thread William Michels via perl6-users
How would P5 handle line numbers > 10 ? Not getting back line #11 with the P5 examples below: $ raku -ne '.say if ++$ == 3|2|5|11' test_lines.txt Line 2 Line 3 Line 5 Line 11 ~$ perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt Line 1 Line 2 Line 3 Line 5 ~$ perl -ne 'print if $. =~

Re: print particular lines question

2020-08-31 Thread Brian Duggan
On Monday, August 31, Andy Bach wrote: > > raku -ne '.say if $++ == 3|2|5' Lines.txt > > OT, maybe, but is > perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt > > or > perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt > > the best you can do in P5? I can't think of anything better :-) Brian

Re: print particular lines question

2020-08-31 Thread Andy Bach
st 31, 2020 7:53 AM To: Curt Tilmes Cc: perl6-users Subject: Re: print particular lines question On Monday, August 24, Curt Tilmes wrote: > $ cat Lines.txt | raku -e '.say for lines()[3,2,5]' The -n flag is an option here too: raku -ne '.say if $++ == 3|2|5' Lines.txt Brian

Re: print particular lines question

2020-08-31 Thread Brian Duggan
On Monday, August 24, Curt Tilmes wrote: > $ cat Lines.txt | raku -e '.say for lines()[3,2,5]' The -n flag is an option here too: raku -ne '.say if $++ == 3|2|5' Lines.txt Brian

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-29 Thread William Michels via perl6-users
Dear Tobias (and Sean), I opened a Github issue: https://github.com/rakudo/rakudo/issues/3881 On Wed, Aug 26, 2020 at 12:12 PM Tobias Boege wrote: > On Wed, 26 Aug 2020, Tobias Boege wrote: > > Observe: > > > > > 1 ...^ 20 > > (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) > > > > > 1

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread Tobias Boege
On Wed, 26 Aug 2020, Tobias Boege wrote: > Observe: > > > 1 ...^ 20 > (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) > > > 1 ... ^20 # actually C«1 ... (0..19)» > (1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19) > > The documentation [1] states that the C«...» infix is

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread William Michels via perl6-users
On Wed, Aug 26, 2020 at 10:33 AM Tobias Boege wrote: > > On Wed, 26 Aug 2020, William Michels via perl6-users wrote: > > > They can be pretty great, especially when combined with the magic op= > > > operators that (in essence) know about identity elements. I've done a > > > few challenges on

Re: Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread Tobias Boege
On Wed, 26 Aug 2020, William Michels via perl6-users wrote: > > They can be pretty great, especially when combined with the magic op= > > operators that (in essence) know about identity elements. I've done a few > > challenges on the Code Golf Stackexchange site where I wanted an infinite > >

Seq whitespace sensitivity? (was Re: print particular lines question)

2020-08-26 Thread William Michels via perl6-users
> They can be pretty great, especially when combined with the magic op= > operators that (in essence) know about identity elements. I've done a few > challenges on the Code Golf Stackexchange site where I wanted an infinite > sequence like this: > > 0, 1, -2, 3, -4, 5, -6, ... > > It took

Re: print particular lines question

2020-08-25 Thread ToddAndMargo via perl6-users
On 2020-08-24 20:30, ToddAndMargo via perl6-users wrote: On Mon, Aug 24, 2020 at 11:08 PM ToddAndMargo via perl6-users wrote: On 2020-08-24 19:35, ToddAndMargo via perl6-users wrote: Hi All, I seems I should know how to do this, but I am drawing a blank. $ cat Lines.txt | raku -ne 'say

Re: print particular lines question

2020-08-25 Thread Bruce Gray
> On Aug 25, 2020, at 4:13 PM, yary wrote: > > > Now, does anyone have a simpler way than using the ".map" above? > > There were a few in the thread! > > Here's my golfing, unlike the others, this preserves the order of the lines > (which may or may not be desired) > > raku -ne '.say if

Re: print particular lines question

2020-08-25 Thread William Michels via perl6-users
,3].join(qq~\n~); " >>> Line 2 >>> Line 8 >>> Line 4 >>> Use of Nil in string context >>> in block at -e line 1 >>> Use of Nil in string context >>> in block at -e line 1 >>> Line 11 >>> >>> and,

Re: print particular lines question

2020-08-25 Thread Sean McAfee
On Tue, Aug 25, 2020 at 2:31 PM Andy Bach wrote: > Pretty cool - I didn't know about the bare "$" as a magic state var. > They can be pretty great, especially when combined with the magic op= operators that (in essence) know about identity elements. I've done a few challenges on the Code Golf

Re: print particular lines question

2020-08-25 Thread Andy Bach
ers ; Parrot Raiser <1parr...@gmail.com>; ToddAndMargo ; Andy Bach ; Curt Tilmes Subject: Re: print particular lines question > Now, does anyone have a simpler way than using the ".map" above? There were a few in the thread! Here's my golfing, unlike the others, this preserve

Re: print particular lines question

2020-08-25 Thread yary
in block at -e line 1 >> >> a >> >> Andy Bach, BS, MSCMECFA >> Systems Mangler >> Internet: andy_b...@wiwb.uscourts.gov >> Voice: (608) 261-5738, Cell: (608) 658-1890 >> >> "The three great problems of computer science: >> compi

Re: print particular lines question

2020-08-25 Thread William Michels via perl6-users
ne' errors". > https://martinfowler.com/bliki/TwoHardThings.html > > -- > *From:* Andy Bach > *Sent:* Tuesday, August 25, 2020 12:18 PM > *To:* Parrot Raiser <1parr...@gmail.com> > *Cc:* perl6-users ; ToddAndMargo < > toddandma..

Re: print particular lines question

2020-08-25 Thread Andy Bach
_ From: Andy Bach Sent: Tuesday, August 25, 2020 12:18 PM To: Parrot Raiser <1parr...@gmail.com> Cc: perl6-users ; ToddAndMargo Subject: Re: print particular lines question On Win10 C:\>type lines.txt | "\Program Files (x86)\rakudo\bin\raku.exe" -ne "say lines()[1

Re: print particular lines question

2020-08-25 Thread Andy Bach
f computer science: compiler complexity and 'off-by-one' errors". https://martinfowler.com/bliki/TwoHardThings.html From: Parrot Raiser <1parr...@gmail.com> Sent: Tuesday, August 25, 2020 11:22 AM To: Andy Bach Cc: perl6-users ; ToddAndMargo Subjec

Re: print particular lines question

2020-08-25 Thread Parrot Raiser
(608) 658-1890 > > Every man has the right to an opinion but no man > has a right to be wrong in his facts. Nor, above all, > to persist in errors as to facts. Bernard Baruch > > ________ > From: ToddAndMargo via perl6-users > Sent: Monday, August 24, 2

Re: print particular lines question

2020-08-25 Thread Andy Bach
errors as to facts. Bernard Baruch From: ToddAndMargo via perl6-users Sent: Monday, August 24, 2020 9:35 PM To: perl6-users Subject: print particular lines question Hi All, I seems I should know how to do this, but I am drawing a blank. $ cat Lines.txt | raku -ne 's

Re: print particular lines question

2020-08-24 Thread ToddAndMargo via perl6-users
On Mon, Aug 24, 2020 at 11:08 PM ToddAndMargo via perl6-users wrote: On 2020-08-24 19:35, ToddAndMargo via perl6-users wrote: Hi All, I seems I should know how to do this, but I am drawing a blank. $ cat Lines.txt | raku -ne 'say $_;' Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8

Re: print particular lines question

2020-08-24 Thread Curt Tilmes
$ cat Lines.txt | raku -e '.say for lines()[3,2,5]' On Mon, Aug 24, 2020 at 11:08 PM ToddAndMargo via perl6-users wrote: > > On 2020-08-24 19:35, ToddAndMargo via perl6-users wrote: > > Hi All, > > > > I seems I should know how to do this, but > > I am drawing a blank. > > > > $ cat Lines.txt |

Re: print particular lines question

2020-08-24 Thread ToddAndMargo via perl6-users
On 2020-08-24 19:35, ToddAndMargo via perl6-users wrote: Hi All, I seems I should know how to do this, but I am drawing a blank. $ cat Lines.txt | raku -ne 'say $_;' Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 Line 11 I want to print liens 1, 3, and 7. Assigning 

print particular lines question

2020-08-24 Thread ToddAndMargo via perl6-users
Hi All, I seems I should know how to do this, but I am drawing a blank. $ cat Lines.txt | raku -ne 'say $_;' Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 Line 11 I want to print liens 1, 3, and 7. Assigning `my @x=$_.lines` puts everything into $x[0] Many thanks,