Re: More efficient of two coding styles?

2018-11-15 Thread Brent Laabs
> > Which coding idiom is better in performance terms? > > May be my question is "incorrect", in which case what is the implicit > assumption I am making that should be explicit? > > > On 16/11/2018 12:13, Brent Laabs wrote: > > They do two different th

Re: More efficient of two coding styles?

2018-11-15 Thread Brent Laabs
They do two different things. Style 1 will throw a dispatch error if $ node.name has a value of 'three', where Style 2 will do nothing in that case. On Thu, Nov 15, 2018 at 7:55 PM Richard Hainsworth wrote: > Suppose I have a sub called C that runs different code depending > on the content of a

Re: need p5/p6 :: help

2018-09-15 Thread Brent Laabs
Now that Larry has spoken on the issue of vocabulary, it's lexicanonical. On Fri, Sep 14, 2018 at 12:49 PM Larry Wall wrote: > On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote: > : Also, did you answer my question about "::" and did it > : just go over my head? > > The implication wa

Re: I need hash syntax help

2018-09-15 Thread Brent Laabs
Because << >> is a double-quoted index (same as quote words «»), so it interpolates the variable. <> is a single-quoted string, so it doesn't interpolate. But what you really want here is %x{$z}, so you don't bother with string interpolation at all, and pass the String variable directly. On Fri,

Re: a `pe4rl6 -c` error to fix

2018-06-20 Thread Brent Laabs
-c does compile time warnings, not runtime warnings. You can't make runtime warnings appear at compile time without using a BEGIN block. On Wed, Jun 20, 2018 at 9:59 PM, Todd Chester wrote: > > > > On Tue, Jun 19, 2018 at 10:50 PM, Todd Chester > wrote: > >> Dear Perl Developers, > >> > >> Wou

Re: need sort help

2018-06-08 Thread Brent Laabs
It isn't in any variable, @x.sort got called in sink context. You'll have to assign it if you want, maybe use @x.=sort ? I just wanted to give an example of how to solve the problem, not necessarily a working solution. First of all, I did thinko the solution -- element 6 is [5]... and we don't

Re: need sort help

2018-06-08 Thread Brent Laabs
, Jun 8, 2018 at 6:59 PM, Brent Laabs wrote: > If possible, you should change the way the files come, or rename them when > you get them, or open an issue to use a proper output log format. > > I mean, you can sort like: > @x.sort: { > my $a = $^a ~~ m:g/\d+/; > my $b = $^b

Re: need sort help

2018-06-08 Thread Brent Laabs
log.06-08-2018_17:07:39.zip >>> log.07-08-2018_06:07:39.zip >>> log.07-08-2018_16:07:39.zip >>> log.12-08-2016_06:07:39.zip >>> ) >>> >>> >>> 2016 should be at the top. >>> >>> >>> Many thanks, >&g

Re: need sort help

2018-06-08 Thread Brent Laabs
Rename all of the input files using ISO 8601 dates. I can't tell, from looking at those numbers, if the first field is the month or the day, so it's impossible to sort data like that with certainty. On Fri, Jun 8, 2018 at 5:15 PM, ToddAndMargo wrote: > Hi All, > > https://docs.perl6.org/routine

Re: How to print colorized text to the terminal

2018-06-03 Thread Brent Laabs
You might want to consider using Terminal::ANSIColor. On Sun, Jun 3, 2018 at 5:53 PM, Xin Cheng wrote: > I just tried to use "put" in place of "say", and got the same result. > > Thanks. > > Ziping > > > On Jun 3, 2018, at 8:44 PM, Brandon Allbery wrote: > > "say" uses the .gist method, which q

Re: Real, Num, Rat question

2018-05-27 Thread Brent Laabs
Real is a role, not a type. Both Num and Rat happen to do Real, so the type checking is ok. This would work OK with a type too -- you can safely store a Num in a `my Cool $foo` as well. You can't do anything to make the ^name method return Real. There are a few ways to check this, though. The

Re: number of letters question

2018-05-15 Thread Brent Laabs
Just a quick reminder that matches the underscore, because also does. If you want to exclude underscores, you can match against /<+alnum-[_]>/. That adds the alnum character class, but subtracts underscores from it. Decimal points are definitely not alphanumeric, though. On Tue, May 15, 2018

Re: odd and even

2018-05-01 Thread Brent Laabs
Yeah, that lexiconic section sounded a bit hyperbolic. On Tue, May 1, 2018 at 6:17 PM, Larry Wall wrote: > On Tue, May 01, 2018 at 01:43:44AM -0700, ToddAndMargo wrote: > : The worst thing I had problems with in Perl was folks telling it > : was "Lexiconical". What? I wish they would have also

Re: need s/ help

2018-05-01 Thread Brent Laabs
That last one has a special case available, but it's slightly less portable. But afaik it works on all platforms we actually support: > perl6 -e '"screws/nuts/bolts/washers".path.parent.Str.say' screws/nuts/bolts On Tue, May 1, 2018 at 4:37 PM, ToddAndMargo wrote: > On 05/01/2018 04:29 PM, Tod

Re: who own my code?

2017-10-21 Thread Brent Laabs
This depends on the contract you signed with the customer, and laws in your local jurisdiction. As such, it's probably a question more appropriate to ask a lawyer than this list. On Sat, Oct 21, 2017 at 12:57 AM, ToddAndMargo wrote: > On 10/21/2017 12:40 AM, ToddAndMargo wrote: > >> If I write

Re: Is Haskell the right language for teaching FP. No!

2017-10-16 Thread Brent Laabs
It'd probably be just as useful to reply here: https://news.ycombinator.com/item?id=15483195 On Mon, Oct 16, 2017 at 5:03 PM, Norman Gaywood wrote: > Someone should mention perl6 :-) > > http://profsjt.blogspot.com.au/2017/10/is-haskell-right- > language-for-teaching.html > > -- > Norman Gaywood

Re: variable size limit?

2017-10-02 Thread Brent Laabs
I'd recommend using less memory in a variable than your system has in physical RAM, or your program will get slow from swapping to disk. I've never had a computer with less than 8MB of memory, so you should be fine. On Mon, Oct 2, 2017 at 6:22 PM, ToddAndMargo wrote: > Hi All, > > I am about to

Re: Why can't I "write"?

2017-09-23 Thread Brent Laabs
OK, a method is something you call on an object, using a the dot operator. A subroutine is an independent object installed into your current lexical scope. If write was a sub, it would work exactly as you described: 48: my $Handle = open( $DateFile, :rw ) 53: write( $Handle, $OldDateTime

Re: help with map and regexp

2017-09-21 Thread Brent Laabs
You can also use a whatever star with the subst method to avoid the block entirely, and just chain method calls: my @fields = $line.split( ',' ).map: *.subst(/\'/, "", :g).subst(/^\"|\"$/, "", :g); On Wed, Sep 20, 2017 at 11:37 PM, Luca Ferrari wrote: > On Tue, Sep 19, 2017 at 2:43 PM, Timo Pa

Re: Help me be greedy!

2017-08-04 Thread Brent Laabs
PCRE has the /U flag that reverses the behavior of .* and .*? ( *PCRE_UNGREEDY)* This was always a terrible idea, and is probably the source of your confusion. On Fri, Aug 4, 2017 at 12:38 PM, Brandon Allbery wrote: > Like I said, greedy is the default, *.? says *don't* be greedy. You wanted >

Re: String to array problem

2017-07-17 Thread Brent Laabs
Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo >> <mailto:toddandma...@zoho.com>> wrote: >>> >>> On 07/16/2017 07:48 PM, Brent Laabs wrote: >>> >>> $ perl6 >>>> my $x='ls -al "Program Files" "

Re: String to array problem

2017-07-17 Thread Brent Laabs
is to say that I wish the Str.words method had a way of applying Perl 6 quoting rules as if it were the qww operator. On Sun, Jul 16, 2017 at 11:34 PM, ToddAndMargo wrote: > On 07/16/2017 07:48 PM, Brent Laabs wrote: > >> $ perl6 >> > my $x='ls -al "Program Files" &

Re: String to array problem

2017-07-16 Thread Brent Laabs
$ perl6 > my $x='ls -al "Program Files" "Moe Curly Larry"'; ls -al "Program Files" "Moe Curly Larry" > &EVAL( "qww<$x>" ).perl ("ls", "-al", "Program Files", "Moe Curly Larry") How about this? Obligatory: Much EVAL, very danger wow. On Sun, Jul 16, 2017 at 6:03 PM, ToddAndMargo wrote: > On 0

Re: How do you call the variable types?

2017-06-09 Thread Brent Laabs
I thought: $ is Scalar @ is Array % is Hash & is a function > my $x; say $x.VAR.WHAT; (Scalar) A dollar variable is a scalar. The Scalar type is the the container for the dollar-variables, just like Array is the container for @array and Hash is the container for %hash. Of course we also have th

Re: ding!

2017-06-01 Thread Brent Laabs
The lack of sound is probably from your terminal. For instance, iTerm2.app has the "Silence Bell" option in Preferences > Profiles. On macOS, this makes a ding noise: perl6 -e 'run ' or perl6 -e 'run ' On Wed, May 31, 2017 at 9:18 PM, ToddAndMargo wrote: > On 05/31/2017 09:11 PM, Peter Scott w

Re: zef, zef-j, zef-m

2017-05-29 Thread Brent Laabs
n 29 May 2017, at 11:22, Fernando Santagata > wrote: > > > > /me sighs: NQP is still so poorly documented! > Believe it or not, this is documented in nqp/docs/ops.markdown in the section under stat. > > > > On Mon, May 29, 2017 at 11:10 AM, Brent Laabs wrote: >

Re: zef, zef-j, zef-m

2017-05-29 Thread Brent Laabs
This works without a module on Rakudo: use nqp; my $path = "foo".IO; my $hardlink-count = nqp::stat($path.absolute, nqp::const::STAT_PLATFORM_NLINKS); On Mon, May 29, 2017 at 1:54 AM, Elizabeth Mattijsen wrote: > > On 29 May 2017, at 10:42, Fernando Santagata > wrote: > > > > The three fil

Re: Get Better error message that "is trait on $-sigil variable not yet implemented. Sorry."?

2017-05-26 Thread Brent Laabs
To file a bug in Rakudo, you should email rakudo...@perl.org. If it's a better error message you want, put "LTA Error" in the email subject somewhere. LTA means "less than awesome", because we in Perl 6 land only accept awesome error messages. If you want to actually have the feature, put "[NYI]

Re: Are sigils required?

2017-05-25 Thread Brent Laabs
You didn't keep reading far enough. > For information on variables without sigils, see sigilless variables . > https://docs.perl6.org/language/variables#Sigilless_variables On Thu, May 25, 2017 at 11:10 PM, Gabor Szabo wrote: > http

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 "$PathAndName" fi > > I am not find

Re: more match humility

2017-03-14 Thread Brent Laabs
I'm not sure what you mean by lexiconical. I can't find any references to it in the official perl documentation (which would technically be lexicanonical, right?). But if you're talking about lexical scope, then yeah, Perl 6 enforces that even more than Perl 5 does by default. On Mon, Mar 13, 20

perl6-users@perl.org

2017-03-08 Thread Brent Laabs
ub LinuxCheck () { print &?ROUTINE ~ " " ~ "$*DISTRO $OS\n"; } >>> >>> >>> rhel linux >>> >>> &?ROUTINE resolves to "", which is not the name of the sub. >>> What am I missing? >>> >>> >>> Many thanks, >>> -T >>> >> > On 03/07/2017 11:42 PM, Brent Laabs wrote: > >> Try &?ROUTINE.name -- that should get you the sub's name. >> >> > Hi Brent, > > Still prints "". Rats! > > Thank you for the help! > -T >

perl6-users@perl.org

2017-03-07 Thread Brent Laabs
Try &?ROUTINE.name -- that should get you the sub's name. On Tue, Mar 7, 2017 at 11:30 PM, ToddAndMargo wrote: > Hi All, > > I am trying to print out the name of the sub I am in. > > Reference: > https://docs.perl6.org/language/variables#index-entry-%26%3FROUTINE > &?ROUTINE Which rout

Re: Is there a list out there of all the \n characters?

2017-03-07 Thread Brent Laabs
Also keep in mind that \v matches one character of vertical space in regexes. Though \n can match one or two charcters, but not all of the Unicode vertical space types. On Tue, Mar 7, 2017 at 12:37 AM, H.Merijn Brand wrote: > On Tue, 7 Mar 2017 00:23:38 -0800, ToddAndMargo > wrote: > > > >>> 0

Re: List

2017-02-06 Thread Brent Laabs
Here are the docs on the List type: https://docs.perl6.org/type/List On Mon, Feb 6, 2017 at 12:40 PM, Bob Goolsby wrote: > Help > > -- > > Bob Goolsby > bob.gool...@gmail.com >

Re: Can I call myself

2017-02-04 Thread Brent Laabs
I think you're looking for &?ROUTINE. &?BLOCK is also related. https://docs.perl6.org/language/variables#index-entry-%26%3FROUTINE On Sat, Feb 4, 2017 at 12:51 AM, Darren Duncan wrote: > Any decent programming language supports self-recursion, where a > subroutine may invoke itself. Perl 6 ex

Re: references and pointers jargon question

2016-01-13 Thread Brent Laabs
Nothing is Forbidden! Everything is Permissible! Also it would make it hard to talk about "is repr('CPointer')" and the Pointer type in NativeCall. While underneath the hood Scalar containers have pointers to values, it's not a particularly useful view of Perl 6. It's more useful to use an OO o

Re: Recalling previous commands

2016-01-01 Thread Brent Laabs
Linenoise is included in Task::Star. https://github.com/tadzik/Task-Star/commit/8ff101ae15 As a bit of history, Linenoise used to be part of the Rakudo repo, but it was split off in the interest of making the base install smaller, keeping separate software separate, and making it more pluggable.

Re: String trim method

2015-08-06 Thread Brent Laabs
I think the optimal way would be: my $s = 'yada yada'; That way the program won't have to trim the whitespace off the string every time it is run. In the more general case, I might do it something like: my $s = something-returning-a-string().trim; But I don't think that there really is a

Re: Sub args: choose one of two?

2015-06-27 Thread Brent Laabs
http://design.perl6.org/S99.html#LTA On Sat, Jun 27, 2015 at 5:57 PM, Tom Browder wrote: > On Jun 27, 2015 7:39 PM, "yary" wrote: > > > > This "sort of" works, in that it does the right thing when you give one > > correct arg, and fails when you give neither arg or both args. The error > > mess

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Brent Laabs
There is nothing exactly like wantarray in Perl 6. Functions can no longer return different values based on context, because as Darren mentioned above, it's a Bad Thing. There are a few ways of doing something similar by returning mixins, perhaps something like return $num but [$num, $num2]; (w