File::Copy ??

2017-03-21 Thread ToddAndMargo
Hi All, Do we have anything like http://perldoc.perl.org/File/Copy.html under another name? Nothing showed up in https://modules.perl6.org/#q=file%3A%3A Many thanks, -T -- Yesterday it worked. Today it is not working. Windows is like that.

[perl #131008] lcm should not work with Nums, and maybe gcd too (2.5 lcm 5)

2017-03-21 Thread Zoffix Znet via RT
Thank you for the report. However, there's no bug here and I'm going to reject this ticket. > Another option is to make it return 5 (kinda DWIM) No, it's not another option because that doesn't make any sense mathematically. The math operations lcm[^1] and gcd[^2] ops perform apply to integer

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
Thank you all for the wonderful training and feedback!

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
On 03/21/2017 11:25 AM, Brandon Allbery wrote: people comparing perl 5 speed to perl 6 should take note: perl 5 used to be slow too If you wanted "speed", code in C or assembly. I am after rapid development. Perl 6 is perfect. -- ~~ Computers are like

Re: maintainability and "or"

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:50 AM, Elizabeth Mattijsen wrote: $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; Hi Liz, Now that is elegant! Thank you! -T -- ~~ Computers are like air conditioners. They malfunction when you open windows

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 08:10 AM, Parrot Raiser wrote: "Premature optimisation is the root of many evils", or words to that effect. (I forget who said it, but I think it was someone credible.) Write your code as clearly and simply as you can, then see if it performs adequately under load. If it does,

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 05:05 AM, Timo Paulssen wrote: Shifting from the front will just move the "beginning" pointer one slot forwards, and popping will decrease the "element count" number. I'm not sure if splice with an empty "insertion" list that happens to be at the end will also just reduce the

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:46:43PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 2:37 PM, Patrick R. Michaud > wrote: > > > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo > > wrote: > > > > $Name.IO.f or $Name.IO.open(:w).close; > > > > > >

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 2:37 PM, Patrick R. Michaud wrote: > On Tue, Mar 21, 2017 at 02:25:02PM -0400, Brandon Allbery wrote: > > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo > wrote: > > > $Name.IO.f or $Name.IO.open(:w).close; > > > > fwiw I

Re: maintainability and "or"

2017-03-21 Thread The Sidhekin
On Tue, Mar 21, 2017 at 7:28 PM, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 7:50 AM, Elizabeth Mattijsen > wrote: > >> $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; > > > This has a readability issue, though: you've buried the lede.

Re: Is this file check backwards?

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 5:52 AM, ToddAndMargo wrote: > Sound backwards to me. What am I missing? Conditionals in all language have a semantic gap issue. Test conditions are often the reverse of what makes for good code --- which is why you find inverted conditionals in

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:25:02PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo wrote: > > $Name.IO.f or $Name.IO.open(:w).close; > > fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly > poor one for readability and

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 7:50 AM, Elizabeth Mattijsen wrote: > $PathAndName.IO.open(:w).close unless $PathAndName.IO.f; This has a readability issue, though: you've buried the lede. The condition should be up front where it stands out, not hidden at the back. The wide usage

Re: maintainability and "or"

2017-03-21 Thread Brandon Allbery
On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo wrote: > $Name.IO.f or $Name.IO.open(:w).close; fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly poor one for readability and maintainability, but one that used to be fairly important (people

Re: Question for the developers on splice

2017-03-21 Thread Parrot Raiser
"Premature optimisation is the root of many evils", or words to that effect. (I forget who said it, but I think it was someone credible.) Write your code as clearly and simply as you can, then see if it performs adequately under load. If it does, you're finished. If it doesn't, instrument and

Re: maintainability and "or"

2017-03-21 Thread H.Merijn Brand
On Tue, 21 Mar 2017 12:50:18 +0100, Elizabeth Mattijsen wrote: > > On 21 Mar 2017, at 12:38, ToddAndMargo wrote: > > This is just one of those chatter posts. > > > > To me, the holy grail of coding is maintainability, > > which is why I code in Top Down.

Re: Question for the developers on splice

2017-03-21 Thread Timo Paulssen
Shifting from the front will just move the "beginning" pointer one slot forwards, and popping will decrease the "element count" number. I'm not sure if splice with an empty "insertion" list that happens to be at the end will also just reduce the number of elements or if it does a bit of

Re: maintainability and "or"

2017-03-21 Thread Elizabeth Mattijsen
> On 21 Mar 2017, at 12:38, ToddAndMargo wrote: > This is just one of those chatter posts. > > To me, the holy grail of coding is maintainability, > which is why I code in Top Down. > > Code like below get my goat because I have to look > at it several times before I

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:27 AM, Philip Hazelden wrote: $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Note, the following sequence is possible: 1. .IO.f returns false 2. Someone creates the file and writes some data to it 3. .IO.open truncates the file Thus, this has a chance of editing the

maintainability and "or"

2017-03-21 Thread ToddAndMargo
Hi All, This is just one of those chatter posts. To me, the holy grail of coding is maintainability, which is why I code in Top Down. Code like below get my goat because I have to look at it several times before I realize what is going on $Name.IO.f or $Name.IO.open(:w).close; Basically the

Re: How to I create a file?

2017-03-21 Thread Philip Hazelden
> $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Note, the following sequence is possible: 1. .IO.f returns false 2. Someone creates the file and writes some data to it 3. .IO.open truncates the file Thus, this has a chance of editing the file. I suggest instead (untested):

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 04:02 AM, Simon Proctor wrote: It's a logical test but I'd probably use || instead. Thank you!

Re: How to I create a file?

2017-03-21 Thread Simon Proctor
It's a logical test but I'd probably use || instead. See : https://docs.perl6.org/language/traps#Loose_boolean_operators On Tue, 21 Mar 2017 at 10:56 ToddAndMargo wrote: > On 03/21/2017 03:07 AM, Brent Laabs wrote: > > $PathAndName.IO.f or

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:07 AM, Brent Laabs wrote: $PathAndName.IO.f or $PathAndName.IO.open(:w).close; Is that a coding "or" or an English "or"? -- ~~ Computers are like air conditioners. They malfunction when you open windows

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:50 AM, Simon Proctor wrote: .e checks a path exists. .f checks it exists AND is a file. .d checks it exists AND is a directory. (Perl 5 was the -e, -f and -d tests) Beautiful explanation! Thank you! Perl 5 has the (about) same test as bash and I write a lot in that too. (I

Re: How to I create a file?

2017-03-21 Thread Simon Proctor
.e checks a path exists. .f checks it exists AND is a file. .d checks it exists AND is a directory. (Perl 5 was the -e, -f and -d tests) On Tue, 21 Mar 2017 at 10:19 ToddAndMargo wrote: > On 03/21/2017 03:07 AM, Brent Laabs wrote: > > You can create a file by opening a

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On 03/21/2017 03:07 AM, Brent Laabs wrote: You can create a file by opening a filehandle for writing. $PathAndName.IO.f or $PathAndName.IO.open(:w).close; What does the .f do? -- ~~ Computers are like air conditioners. They malfunction when you open

Re: How to I create a file?

2017-03-21 Thread ToddAndMargo
On Tue, Mar 21, 2017 at 3:01 AM, ToddAndMargo > wrote: Hi All, How to I do this bash code in Perl 6? if [ ! -f "$PathAndName" ]; then touch "$PathAndName" fi I am not finding the directions on how to create a "new" file

Re: How to I create a file?

2017-03-21 Thread Brent Laabs
You can create a file by opening a filehandle for writing. $PathAndName.IO.f or $PathAndName.IO.open(:w).close; On Tue, Mar 21, 2017 at 3:01 AM, ToddAndMargo wrote: > Hi All, > > How to I do this bash code in Perl 6? > > if [ ! -f "$PathAndName" ]; then touch

Re: Is this file check backwards?

2017-03-21 Thread ToddAndMargo
On Tue, 21 Mar 2017 at 09:53 ToddAndMargo > wrote: https://docs.perl6.org/language/io.html From the above manual, the example to check if a file exists: if "nonexistent_file".IO.e { say "file exists"; } else {

How to I create a file?

2017-03-21 Thread ToddAndMargo
Hi All, How to I do this bash code in Perl 6? if [ ! -f "$PathAndName" ]; then touch "$PathAndName" fi I am not finding the directions on how to create a "new" file at a specific location. Many thanks, -T -- ~~ Computers are like air conditioners. They

Re: Question for the developers on splice

2017-03-21 Thread ToddAndMargo
On 03/21/2017 02:14 AM, Elizabeth Mattijsen wrote: On 21 Mar 2017, at 10:00, ToddAndMargo wrote: on this command: perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' Are you actually moving one set up data into another set's element/slot/index, or are you just

Re: Is this file check backwards?

2017-03-21 Thread Simon Proctor
Just because the file is called "nonexistent_file" doesn't mean is doesn't exist. It's a poorly written example really. if "possibly_existing_file".IO.e { say "file exists"; } else { say "file doesn't exist"; } Is more intuitive I would say. On Tue, 21 Mar 2017 at 09:53 ToddAndMargo

Is this file check backwards?

2017-03-21 Thread ToddAndMargo
https://docs.perl6.org/language/io.html From the above manual, the example to check if a file exists: if "nonexistent_file".IO.e { say "file exists"; } else { say "file doesn't exist"; } Sound backwards to me. What am I missing? Many thanks, -T -- ~ I

Re: Question for the developers on splice

2017-03-21 Thread Elizabeth Mattijsen
> On 21 Mar 2017, at 10:00, ToddAndMargo wrote: > on this command: > > perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' > > Are you actually moving one set up data into another set's > element/slot/index, or are you just rearranging the pointers > to each element? How

Question for the developers on splice

2017-03-21 Thread ToddAndMargo
Dear Developers, on this command: perl6 -e 'my @foo = ; @foo.splice(0,3); say @foo;' Are you actually moving one set up data into another set's element/slot/index, or are you just rearranging the pointers to each element? Many thanks, -T -- ~~~ Having been erased,

Re: How do I remove N elements

2017-03-21 Thread ToddAndMargo
On 03/20/2017 11:18 PM, Norman Gaywood wrote: On 21 March 2017 at 15:39, ToddAndMargo > wrote: from the beginning of an array? untested but same as perl5: splice @list, 0, $N; https://docs.perl6.org/routine/splice

Re: RFE: throw an error on a single "="when used in an "if"

2017-03-21 Thread Francesco Rivetti
On 20. mars 2017 15:54, Patrick R. Michaud wrote: On Mon, Mar 20, 2017 at 02:36:49PM +0100, Francesco Rivetti wrote: On 18. mars 2017 11:54, Elizabeth Mattijsen wrote: if (my $x = frobnicate(42)) { say $x } [...] if frobnicate(42) -> $x { say $x } which is way more elegant. Should

Re: How do I remove N elements

2017-03-21 Thread Norman Gaywood
On 21 March 2017 at 15:39, ToddAndMargo wrote: > from the beginning of an array? > untested but same as perl5: splice @list, 0, $N; https://docs.perl6.org/routine/splice > I know about shift, but that is one at a time. I suppose I > could do a loo[, but it would be