Re: Dual Buf and Str question

2022-06-11 Thread ToddAndMargo via perl6-users
On 6/9/22 22:54, ToddAndMargo via perl6-users wrote: Hi All, I can easily  get away with this in Modula2, but how can I do this with Raku? I wish to create a single variable that can be manipulated in two ways: 1) as a fixed length string (Str) 2) as a fixed length buffer (Buf) I can think o

Re: Dual Buf and Str question

2022-06-10 Thread ToddAndMargo via perl6-users
On 6/10/22 02:36, Elizabeth Mattijsen wrote: On 10 Jun 2022, at 11:20, ToddAndMargo via perl6-users wrote: On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users wrote: Hi All, I can easily get away with this in Modula2, but how can I do this with Raku? I wish to create a single variabl

Re: Dual Buf and Str question

2022-06-10 Thread Elizabeth Mattijsen
> On 10 Jun 2022, at 11:20, ToddAndMargo via perl6-users > wrote: > >>> On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users >>> wrote: >>> >>> Hi All, >>> >>> I can easily get away with this in Modula2, but >>> how can I do this with Raku? >>> >>> I wish to create a single variable that

Re: Dual Buf and Str question

2022-06-10 Thread ToddAndMargo via perl6-users
On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users wrote: Hi All, I can easily get away with this in Modula2, but how can I do this with Raku? I wish to create a single variable that can be manipulated in two ways: 1) as a fixed length string (Str) 2) as a fixed length buffer (Buf) I

Re: Dual Buf and Str question

2022-06-10 Thread Elizabeth Mattijsen
Perhaps https://raku.land/zef:raku-community-modules/Pythonic::Str is what you're after? > On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users > wrote: > > Hi All, > > I can easily get away with this in Modula2, but > how can I do this with Raku? > > I wish to create a single variable th

Dual Buf and Str question

2022-06-09 Thread ToddAndMargo via perl6-users
Hi All, I can easily get away with this in Modula2, but how can I do this with Raku? I wish to create a single variable that can be manipulated in two ways: 1) as a fixed length string (Str) 2) as a fixed length buffer (Buf) I can think of ways to do this, but it would require separate varia

Re: REPL / Linenoise question (backslashes)

2021-07-21 Thread Brian Duggan
On Wednesday, July 21, William Michels wrote: > Sorry for my continuing confusion, but I don't see any use-case for an > "unspace" at the end of a line in the Raku REPL, or the Jupyter > kernel. A use case would be for instance, wanting to call a method on the next line -- so wanting to unspace t

Re: REPL / Linenoise question (backslashes)

2021-07-21 Thread William Michels via perl6-users
Dear Brian, Thank you for your analysis! I am particularly intrigued by your Jupyter comment: "Note that this is not the same as the raku 'unspace' -- a backslash followed by a newline will be replaced with a newline before the code is executed. To create an unspace at the end of the line, you ca

Re: REPL / Linenoise question (backslashes)

2021-07-20 Thread Brian Duggan
On Monday, July 19, William Michels via perl6-users wrote: > I don't see how the Raku REPL knows how to cycle from taking input at its > prompt and moving to the read/evaluate step. This currently happens when the parser throws one of these exceptions: X::Syntax::Missing X::Comp::FailGoal

Re: REPL / Linenoise question (backslashes)

2021-07-19 Thread William Michels via perl6-users
Hi Rob! Thanks for the reply. So what you're saying is the "backslash-newline" combination tells the REPL that it has received incomplete input? Otherwise I don't see how the Raku REPL knows how to cycle from taking input at its prompt and moving to the read/evaluate step. I took a quick look at

Re: REPL / Linenoise question (backslashes)

2021-07-17 Thread rir
On Wed, Jul 14, 2021 at 08:40:07AM -0700, William Michels via perl6-users wrote: > > \ > {} > > \\ > {} > > \\\ > {} > Curiously, I seem to create an object in my REPL environment when I enter > either a single-, double-, or triple-backslash. ... Your backslash destroys the newline so the inpu

Re: XML module question?

2021-07-17 Thread William Michels via perl6-users
o a valid XML file: raku -MXML::Writer -e 'my @reordered = do for lines() {(.words[3..*],.words[0..2]).join(" ")}; say XML::Writer.serialize(@reordered.flat);' ../lat_lon.txt The XML tree must have a single root node As a more general question, I'm still amazed at the effect

Re: XML module question?

2021-07-16 Thread Bruce Gray
David, Aha! I am very glad to be wrong! $ raku -MXML::Writer -ne 'print XML::Writer.serialize: :wpt[ :lat(.words[5].subst(";")), :lon(.words[8]), :time[.words.head(3).join(" ")] ];' lat_lon.txt 11-06-2014 - 10:49:06PM 11-06-2014 - 10:49:49PM 11-06-2014 - 10:50:35PM 11-06-2014 - 10:51:21PM 11-0

Re: XML module question?

2021-07-16 Thread David Warring
The XML::Writer module side-steps any ordering issues by directly serializing data structures to xml: $ raku -M XML::Writer -e'say XML::Writer.serialize: :wpt[ :lat<42>, :long<69>, "blah" ]' blah On Sat, Jul 17, 2021 at 4:48 AM Bruce Gray wrote: > > On Jul

Re: XML module question?

2021-07-16 Thread Bruce Gray
> On Jul 15, 2021, at 11:02 PM, William Michels via perl6-users > wrote: (and I re-ordered): > Any help appreciated, > Thanks, Bill. > REFERENCE: https://unix.stackexchange.com/q/166675/227738 > I'm trying to put an answer together for SO, and I keep running into the same > difficulty. Give

XML module question?

2021-07-15 Thread William Michels via perl6-users
Hi, I'm trying to put an answer together for SO, and I keep running into the same difficulty. Given a CSV file, how can one produce an XML file with latitude and longitude values properly quoted? Every time I get proper quoting, "lat" and "lon" are scrambled (i.e. sometimes "lat" first, sometimes

REPL / Linenoise question (backslashes)

2021-07-14 Thread William Michels via perl6-users
Hi, I've recently updated my Rakudo installation, and I wanted to test multi-line input in the REPL. By mistake I entered a backslash at the REPL command line: user@mbook:$ raku Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.06. Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d. Built on MoarVM version 2021.06. To exit

Re: array and class question

2021-07-04 Thread ToddAndMargo via perl6-users
On 4 Jul 2021, at 12:36, ToddAndMargo via perl6-users wrote: Hi All, What I am doing wrong here? class UupDumpClass { has @.arry is rw; } (UupDumpClass) my $x = UupDumpClass; (UupDumpClass) $x.arry[0] = "zero"; Cannot look up attributes in a UupDumpClass type object in method arry a

Re: array and class question

2021-07-04 Thread Elizabeth Mattijsen
my $x = UupDumpClass.new; > On 4 Jul 2021, at 12:36, ToddAndMargo via perl6-users > wrote: > > Hi All, > > What I am doing wrong here? > > > class UupDumpClass { has @.arry is rw; } > (UupDumpClass) > > > my $x = UupDumpClass; > (UupDumpClass) > > > $x.arry[0] = "zero"; > Cannot look up att

array and class question

2021-07-04 Thread ToddAndMargo via perl6-users
Hi All, What I am doing wrong here? > class UupDumpClass { has @.arry is rw; } (UupDumpClass) > my $x = UupDumpClass; (UupDumpClass) > $x.arry[0] = "zero"; Cannot look up attributes in a UupDumpClass type object in method arry at line 1 in block at line 1 Many thanks, -T --

Re: A nextsame question

2021-01-19 Thread Fernando Santagata
ut yourself in the shoes of your code user, imagine that you > introspect the multi in question with 'cando' which gives you the candidate > returning a List. It'd be very confusing to get an Int instead! > > Aside of this, the practice of returning so different values fo

Re: A nextsame question

2021-01-19 Thread Vadim Belman
be to think of it as of 'return next-candidate(...)'. I would say that this is the semantics which cares about the caller. If you put yourself in the shoes of your code user, imagine that you introspect the multi in question with 'cando' which gives you the candidate returnin

A nextsame question

2021-01-19 Thread Fernando Santagata
Hello, I'm trying to understand how nextsame works. Apparently I started from the wrong assumptions: I thought that once the first matched sub in the chain called nextsame, the arguments were matched against the following subs regardless of the return value. It seems that while the return value is

Re: for and ^ question

2021-01-02 Thread ToddAndMargo via perl6-users
On 1/1/21 10:47 PM, Patrick R. Michaud wrote: On Fri, Jan 01, 2021 at 05:41:04PM -0800, ToddAndMargo via perl6-users wrote: On 1/1/21 6:32 AM, David Santiago wrote: say $_ for {0.1+$_}...^5 Is there a way to do this without the finger wagging? say $_ for {0.1+$_}...^2 If you're going to a

Re: for and ^ question

2021-01-01 Thread Patrick R. Michaud
On Fri, Jan 01, 2021 at 05:41:04PM -0800, ToddAndMargo via perl6-users wrote: > On 1/1/21 6:32 AM, David Santiago wrote: > > say $_ for {0.1+$_}...^5 > > Is there a way to do this without the finger wagging? > > say $_ for {0.1+$_}...^2 If you're going to a sequence operator ("...") instead of a

Re: for and ^ question

2021-01-01 Thread ToddAndMargo via perl6-users
On 1/1/21 6:32 AM, David Santiago wrote: say $_ for {0.1+$_}...^5 Hi David, Thank you! Is there a way to do this without the finger wagging? say $_ for {0.1+$_}...^2 Use of uninitialized value of type Any in numeric context in block at line 1 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.

Re: for and ^ question

2021-01-01 Thread David Santiago
> for .1^...5 {print "$_\n";} 1.1 2.1 3.1 4.1 both still increments by 1 What am I doing wrong? do this if you want to increment by 0.1: say $_ for {0.1+$_}...^5 Best regards, David Santiago

Re: for and ^ question

2021-01-01 Thread ToddAndMargo via perl6-users
On 1/1/21 3:23 AM, Kevin Pye wrote: ..^ is an operator. You can't put spaces in the middle of an operator. > for ^2.1..4.5 {print "$_\n";} Range objects are not valid endpoints for Ranges in block at line 1 > for 2.1^..4.5 {print "$_\n";} 3.1 4.1 > for .1^...5 {print "$_\n";} 1.1 2.1 3.1

Re: for and ^ question

2021-01-01 Thread Kevin Pye
..^ is an operator. You can't put spaces in the middle of an operator. On Fri, 1 Jan 2021 at 22:13, ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > >> On Fri, 1 Jan 2021 at 18:59, ToddAndMargo via perl6-users > >> mailto:perl6-users@perl.org>> wrote: > >> > >> >> ^ note: ^3

Re: for and ^ question

2021-01-01 Thread ToddAndMargo via perl6-users
On Fri, 1 Jan 2021 at 18:59, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: >> ^ note: ^3 means the integer "just before" 3 (zero is presume to be the >> start point) >> >>3^ means the integer "just after" 3 (an ending poin

Re: for and ^ question

2021-01-01 Thread Kevin Pye
We have established that ^2.1 is a range, meaning all the real numbers from 0 to 2.1, not including the 2.1. What do you expect ^2.1 .. 2.5 to mean, That's a range (the "..") from "^2.1", another range to the number 2.5. You can't have a range starting with a range, A range is between two numbers

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
^ note: ^3 means the integer "just before" 3 (zero is presume to be the start point) 3^ means the integer "just after" 3 (an ending point is required) On 12/31/20 10:15 PM, Kevin Pye wrote: No, it does not. Go back and read what Brad wrote; he was quite explicit.

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
^ note: ^3 means the integer "just before" 3 (zero is presume to be the start point) 3^ means the integer "just after" 3 (an ending point is required) On 12/31/20 10:15 PM, Kevin Pye wrote: No, it does not. Go back and read what Brad wrote; he was quite explicit.

Re: for and ^ question

2020-12-31 Thread Kevin Pye
> > ^ note: ^3 means the integer "just before" 3 (zero is presume to be the > start point) > > 3^ means the integer "just after" 3 (an ending point is > required) > No, it does not. Go back and read what Brad wrote; he was quite explicit. Nothing about the range 0 ..^ 3 (for which "^3

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
On 12/31/20 1:56 PM, Brad Gilbert wrote: just before Hi Brad, Believe it or not, things fell into place with just those two word from your letter. Excellent! -T

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
On 12/30/20 5:39 PM, ToddAndMargo via perl6-users wrote: Hi All, In the following for loop:     for ^$nCount -> $i { What is the ^ doing? Confused again, -T With wonderful explanations for many others, my notes: ^ note: ^3 means the integer "just before" 3 (zero is presume to be the st

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
On 12/31/20 1:56 PM, Brad Gilbert wrote: It does not look like an array from 0 to ($nCount - 1). It only iterates like that. It is a Range object from 0 to $nCount excluding $nCount.     ^9 === Range.new( 0, 9, :excludes-max ) # True     0 ~~ ^9 # True     1 ~~ ^9 # True     0.5 ~~ ^9 # Tr

Re: for and ^ question

2020-12-31 Thread ToddAndMargo via perl6-users
On 12/31/20 7:44 AM, William Michels via perl6-users wrote: There's an open Github issue on the interaction between Seqs and carets: https://github.com/rakudo/rakudo/issues/3881 Scroll down to the section entitled, "EDIT 08/29/2020 -- TL;DR Version" for the crux of the issue. > 8 ... ^16 #

Re: for and ^ question

2020-12-31 Thread Brad Gilbert
It does not look like an array from 0 to ($nCount - 1). It only iterates like that. It is a Range object from 0 to $nCount excluding $nCount. ^9 === Range.new( 0, 9, :excludes-max ) # True 0 ~~ ^9 # True 1 ~~ ^9 # True 0.5 ~~ ^9 # True 8 ~~ ^9 # True 8.9 ~~ ^9 # True

Re: for and ^ question

2020-12-31 Thread Andy Bach
PM To: ToddAndMargo Cc: perl6-users Subject: Re: for and ^ question CAUTION - EXTERNAL: Look up ..^ which is the long form of ^ when used in ^8 sort of thing https://docs.raku.org/routine/..$CIRCUMFLEX_ACCENT "Constructs a Range<https://docs.raku.org/type/Range> from the arguments, exclud

Re: for and ^ question

2020-12-31 Thread William Michels via perl6-users
On Wed, Dec 30, 2020 at 7:20 PM ToddAndMargo via perl6-users wrote: > > On 12/30/20 7:06 PM, yary wrote: > > Look up ..^ which is the long form of ^ when used in ^8 sort of thing > > > > https://docs.raku.org/routine/..$CIRCUMFLEX_ACCENT > > > >

Re: a question on use and . in class declarations

2020-12-30 Thread ToddAndMargo via perl6-users
On 12/30/20 5:41 PM, ToddAndMargo via perl6-users wrote: A question on the "use" in a class declaration. In "use $.x". does the dot have a special meaning or is it just to make the value ($.x) easier to access ($objectname.x)? Many thanks, -T From my in p

Re: for and ^ question

2020-12-30 Thread ToddAndMargo via perl6-users
On 12/30/20 7:06 PM, yary wrote: Look up ..^ which is the long form of ^ when used in ^8 sort of thing https://docs.raku.org/routine/..$CIRCUMFLEX_ACCENT "Constructs a Range  from the arguments, excluding

Re: for and ^ question

2020-12-30 Thread yary
Look up ..^ which is the long form of ^ when used in ^8 sort of thing https://docs.raku.org/routine/..$CIRCUMFLEX_ACCENT "Constructs a Range from the arguments, excluding the end point." try out these 3 .. 7 3 ..^ 7 3 ^.. 7 3 ^..^ 7 and also see https://docs.r

Re: for and ^ question

2020-12-30 Thread ToddAndMargo via perl6-users
On 12/30/20 6:04 PM, Curt Tilmes wrote: On Wed, Dec 30, 2020 at 8:40 PM ToddAndMargo via perl6-users wrote: In the following for loop: for ^$nCount -> $i { What is the ^ doing? https://docs.raku.org/type/Range About the third paragraph from the top: The caret is also a prefix opera

Re: for and ^ question

2020-12-30 Thread ToddAndMargo via perl6-users
On 12/30/20 5:39 PM, ToddAndMargo via perl6-users wrote: Hi All, In the following for loop:     for ^$nCount -> $i { What is the ^ doing? Confused again, -T Used in context, the ^ makes the integer $nCount look like an array of 0 to ($nCount - 1). Am I missing something? my $x=4; for ^$x

Re: for and ^ question

2020-12-30 Thread Curt Tilmes
On Wed, Dec 30, 2020 at 8:40 PM ToddAndMargo via perl6-users wrote: > In the following for loop: > > for ^$nCount -> $i { > > What is the ^ doing? https://docs.raku.org/type/Range About the third paragraph from the top: The caret is also a prefix operator for constructing numeric ranges s

a question on use and . in class declarations

2020-12-30 Thread ToddAndMargo via perl6-users
A question on the "use" in a class declaration. In "use $.x". does the dot have a special meaning or is it just to make the value ($.x) easier to access ($objectname.x)? Many thanks, -T

for and ^ question

2020-12-30 Thread ToddAndMargo via perl6-users
Hi All, In the following for loop: for ^$nCount -> $i { What is the ^ doing? Confused again, -T

Re: spurt and array question

2020-11-15 Thread ToddAndMargo via perl6-users
On 2020-11-14 23:56, Fernando Santagata wrote: Oh, now I see: you were asking that question in another thread. I was asking why the \n came out literal in another thread. It did not help I made a syntax boobo. I never got the other ways of writing out the array to work either.

Re: spurt and array question

2020-11-14 Thread Fernando Santagata
Oh, now I see: you were asking that question in another thread. <<>> is equivalent to qq:ww:v as mentioned here: https://docs.raku.org/syntax/%3C%3C%20%3E%3E#index-entry-%3Aval_%28quoting_adverb%29 and as stated here: https://docs.raku.org/language/quoting the adverb :ww splits the

Re: \n and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 18:03, Bruce Gray wrote: On Nov 14, 2020, at 2:06 PM, ToddAndMargo via perl6-users wrote: —snip— But my question still holds. Why is the \n inside the cell printed literally? The two characters, backslash and `n`, are output literally, because you have *input* them

Re: \n and array question

2020-11-14 Thread Bruce Gray
> On Nov 14, 2020, at 2:06 PM, ToddAndMargo via perl6-users > wrote: —snip— > But my question still holds. > Why is the \n inside the cell printed literally? The two characters, backslash and `n`, are output literally, because you have *input* them literally. In single

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 13:39, Fernando Santagata wrote: What do you mean by putting the \n in the variable? $ p6 'my @x = <>; for @x {"$_".print};' aaabbbccc Why are the \n's not being resolved in the above? Why do I have to add an \n to the print line? $ p6 'my @x = <>; for @x {"$_\n".print};' aaa b

Re: spurt and array question

2020-11-14 Thread Fernando Santagata
uot; > > > > Or the equivalent > > > > 'test'.IO.spurt: @a.join("\n") ~ "\n"; > > That is the way around the issue. > > But my question is why can I not put the \n in the variable? > What do you mean by putting the \n in the variable

Re: \n and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 12:03, Brad Gilbert wrote:   I pretty quickly caught my booboo after I pressed send. A little eggs on the face. But my question still holds. Why is the \n inside the cell printed literally?

Re: \n and array question

2020-11-14 Thread Brad Gilbert
ot;;}' > >> aaa > >> bbb > >> ccc > >> > >> $ p6 'my @x = <>; for @x {print "$_";}' > >> aaabbbccc > >> > >> What am I missing? > >> > >> -T > > > On 2020-11-1

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On Sat, Nov 14, 2020 at 1:07 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2020-11-14 06:00, Brad Gilbert wrote: > The purpose of `spurt` is to: > 1. open a NEW file to write to > 2. print a single string > 3. close the file > > If you

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
#x27;, @a.join("\n") ~ "\n");  # join doesn't add the last "\n" Or the equivalent 'test'.IO.spurt: @a.join("\n") ~ "\n"; -- Fernando Santagata That is the way around the issue. But my question is why can I not put the \n in the variable?

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 03:15, Tom Browder wrote: On Sat, Nov 14, 2020 at 01:59 ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, I am writing out an array of text lines to a file. I just can't help but thinking I am doing it the hard way.     unlink( $Leafp

Re: spurt and array question

2020-11-14 Thread Brad Gilbert
Actually no I'm not “forgetting that spurt comes with an `:append` option”. That is a slightly different use case. It is where you are appending to an existing file once, and then never touching it again. (Or maybe you might be touching it again in a few hours.) --- Given that this is what you w

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 03:59, Gianni Ceccarelli wrote: $Leafpadrc.put($_) for @LeafpadrcNew; Cannot resolve caller print(Str:D: BOOTStr); none of these signatures match: (Mu: *%_) in sub RunReport at ./XferParts.pl6 line 229 229: $Leafpadrc.put($_) for @LeafpadrcNew; -- ~

Re: spurt and array question

2020-11-14 Thread Fernando Santagata
On Sat, Nov 14, 2020 at 8:07 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 2020-11-14 06:00, Brad Gilbert wrote: > > The purpose of `spurt` is to: > > 1. open a NEW file to write to > > 2. print a single string > > 3. close the file > > > > If you are calling `spurt` more tha

Re: \n and array question

2020-11-14 Thread ToddAndMargo via perl6-users
;…> and «…» constructors break on whitespace. So will actually produce the following array: ["a,b,c,d,e,f"] It's only one item. If we placed space after the comma, that is, , you'd get a six item list, but with the commas attached to all but the final: ["a,", "b,", "c,", "d,", "e,", "f"] By replacing the commas with spaces, e.g., , you allow it to break into ["a", "b", "c", "d", "e", "f"] Matéu Ya, I caught that booboo. :'( Question still stands. Why is the \n working as a CR/LF and being printed as a litteral?

Re: \n and array question

2020-11-14 Thread Matthew Stuckwisch
The <…> and «…» constructors break on whitespace. So will actually produce the following array: ["a,b,c,d,e,f"] It's only one item. If we placed space after the comma, that is, , you'd get a six item list, but with the commas attached to all but the final: ["a,", "b,", "c,", "d,", "e,

Re: \n and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 11:08, Curt Tilmes wrote: On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users wrote: Just out of curiosity, why is the \n printed out literally here? p6 'my @x = <"aaa\n","bbb\n","ccc\n">; for @x {print @_};' Your 'word quoting' <> is sort of like single quotes -- it ke

Re: \n and array question

2020-11-14 Thread Curt Tilmes
On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users wrote: > Just out of curiosity, why is the \n printed out literally here? > p6 'my @x = <"aaa\n","bbb\n","ccc\n">; for @x {print @_};' Your 'word quoting' <> is sort of like single quotes -- it keeps the literal stuff. You could use <<

Re: spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
On 2020-11-14 06:00, Brad Gilbert wrote: The purpose of `spurt` is to: 1. open a NEW file to write to 2. print a single string 3. close the file If you are calling `spurt` more than once on a given file, you are doing it wrong. You are forgetting that spurt comes with an `:append` option. I

\n and array question

2020-11-14 Thread ToddAndMargo via perl6-users
Hi All, Just out of curiosity, why is the \n printed out literally here? $ alias p6 alias p6='perl6 -e' p6 'my @x = <"aaa\n","bbb\n","ccc\n">; for @x {print @_};' "aaa\n","bbb\n","ccc\n" Many thanks, -T -- ~~ Computers are like air conditioners. They malf

Re: spurt and array question

2020-11-14 Thread Brad Gilbert
The purpose of `spurt` is to: 1. open a NEW file to write to 2. print a single string 3. close the file If you are calling `spurt` more than once on a given file, you are doing it wrong. If you give `spurt` an array, you are probably doing it wrong; unless you want the array turned into a single s

Re: spurt and array question

2020-11-14 Thread Gianni Ceccarelli
On 2020-11-13 ToddAndMargo via perl6-users wrote: > Hi All, > > I am writing out an array of text lines to a file. > I just can't help but thinking I am doing it the > hard way. > > unlink( $Leafpadrc ); > for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", > :append ); } >

Re: spurt and array question

2020-11-14 Thread Tom Browder
On Sat, Nov 14, 2020 at 01:59 ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > I am writing out an array of text lines to a file. > I just can't help but thinking I am doing it the > hard way. > > unlink( $Leafpadrc ); > for @LeafpadrcNew -> $Line { spurt( $Leafpa

spurt and array question

2020-11-14 Thread ToddAndMargo via perl6-users
Hi All, I am writing out an array of text lines to a file. I just can't help but thinking I am doing it the hard way. unlink( $Leafpadrc ); for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", :append ); } If I spurt the array, it converts the array into a single text line. T

Re: lines :$nl-in question

2020-09-02 Thread Larry Wall
Lexically and grammatically, sure, but a lot of the time people are thinking more on the semantic and pragmatic levels. Pragmatically, bus riders, prisoners, and conference listeners are all having something inflicted upon them. :) Glo points out that verbs tend in the pragmatics direction anywa

Re: print particular lines question

2020-09-02 Thread Andy Bach
= $alpha)++; say "d2: " ~ ++$ } }' 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

Re: lines :$nl-in question

2020-09-02 Thread Parrot Raiser
Possibly OT, the "-er/-ee" boundary has become corrupted in recent usage. I suppose "standees" in a bus might be tolerated, depending on your view of transit riders as active or passive, but when a jail-break occurs, the former prisoners should become "escapers", not "escapees". The prison author

Re: print particular lines question

2020-09-01 Thread yary
ninitialized value of type Any in string 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

Re: print particular lines question

2020-09-01 Thread Andy Bach
mething 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: %s\n", $sv ) } }' AA d: AB AB d: AC ____ From: William Michels Sent: Tue

Re: print particular lines question

2020-09-01 Thread William Michels via perl6-users
1..14) { (state $ = $alpha)++; > printf("d: %s\n", $.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 > &

Re: print particular lines question

2020-09-01 Thread Andy Bach
ot;d: %s\n", $.raku⏏ ) } } expecting any of: term 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

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 Tue,

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 $ = 'AAA')+

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, since

Re: liens and :chomp question

2020-09-01 Thread ToddAndMargo via perl6-users
On 2020-09-01 11:14, ToddAndMargo via perl6-users wrote: I see Fedora's docs -- which I use a lot -- uses the same idea: https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/Wayland/ But somehow is a ton more obvious. Reference page: https://docs.fedoraproject.org/e

Re: lines :$nl-in question

2020-09-01 Thread Larry Wall
On Sun, Aug 30, 2020 at 03:12:26PM -0700, yary wrote: : I have a quibble there. 1st & 2nd sentences disagree slightly by going from : active to passive voice. "Caller, the one who calls" vs "object on which : that method is being called" : : Suggestion for 2nd sentence "The invocant of a method wo

Re: liens and :chomp question

2020-09-01 Thread ToddAndMargo via perl6-users
On 2020-08-31 21:48, ToddAndMargo wrote: On 2020-08-30 08:16, yary wrote: Looking up https://docs.raku.org/routine/lines shows a Table of Contents with     class Cool     (Cool) routine lines     class Supply     (Supply) method lines     class Str     (Str) routine lines     class IO::CatHand

Re: lines :$nl-in question

2020-09-01 Thread Richard Hainsworth
---- *From:* William Michels <mailto:w...@caa.columbia.edu>> *Sent:* Sunday, August 30, 2020 2:44:55 PM *To:* yary mailto:not@gmail.com>> *Cc:* perl6-users <mailto:perl6-users@perl.org>>; ToddAndMargo <mailto:to

Re: liens and :chomp question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-30 08:16, yary wrote: Looking up https://docs.raku.org/routine/lines shows a Table of Contents with class Cool (Cool) routine lines class Supply (Supply) method lines class Str (Str) routine lines class IO::CatHandle (IO::CatHandle) method lines cl

Re: liens and :chomp question

2020-08-31 Thread ToddAndMargo via perl6-users
On 2020-08-30 08:16, yary wrote: Expanding on how to read the docs & signature a bit, from Tobias You confuse two methods that have the same name "lines". One of them, which exists in the IO::Path class, has a :chomp argument. The other, on IO::Handle does not.   "path".IO.lines

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
>>> >> >>>> $ raku -ne '.say if $++ == 3|2|5' Lines.txt >> >>>> Line 2 >> >>>> Line 3 >> >>>> Line 5 >> >>>> >> >>>> What is `$++`? >> >>&

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) 94292-6

Re: print particular lines question

2020-08-31 Thread yary
t; What is `$++`? > >>>> > >>>> -T > >>>> > > > > On 2020-08-31 16:36, yary wrote: > >> $ by itself is an anonymous variable, putting ++ after starts it at 0 > >> (hmm or nil?) and increments up. > >> > &g

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
=<"a" "b" "c">; for @x -> $i { print $++," ", ++$, " ", $i, "\n";}' 0 1 "a" 1 2 "b" 2 3 "c" Question: does the counter restart after its use, or do I need to do it myself? -T To an

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
crement versus post increment Hi Yary, Excellent instructions!  It is a counter.   I found it over on     https://docs.raku.org/perl6.html with a search on `$++`.  But I had to pick it up from "context" $ p6 'my @x=<"a" "b" "c">; for @x

Re: print particular lines question

2020-08-31 Thread ToddAndMargo via perl6-users
nt instructions! It is a counter. I found it over on https://docs.raku.org/perl6.html with a search on `$++`. But I had to pick it up from "context" $ p6 'my @x=<"a" "b" "c">; for @x -> $i { print $++," ", ++

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 $++, $ ~=

<    1   2   3   4   5   6   7   8   >