Re: More efficient of two coding styles?

2018-11-15 Thread Brent Laabs
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 things. Style 1 will throw a dispatch error if $ > node.name has a value

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

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

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

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

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
18_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, >>> -T &

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

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

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,

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

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

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

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 >

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: >

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,

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,

Re: String to array problem

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

Re: How do you call the variable types?

2017-06-10 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

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

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

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

Re: Are sigils required?

2017-05-26 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

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

Re: How do I use "&?ROUTINE"?

2017-03-08 Thread Brent Laabs
>>> >>> >>> sub 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 >

Re: How do I use "&?ROUTINE"?

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 >

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

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

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 tom.brow...@gmail.com wrote: On Jun 27, 2015 7:39 PM, yary not@gmail.com 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