Re: A few questions

2009-07-12 Thread yary
On Sun, Jul 12, 2009 at 9:29 AM, Minimiscienceminimiscie...@gmail.com wrote: On Jul 12, 2009, at 12:07 AM, Chas. Owens wrote: Since grep is defined as returning a list of matching elements and first is defined as being the same as grep, I would say that it returns an empty list if nothing

Re: take-ing to-be-modified variables

2009-07-21 Thread yary
A minor point, a capture-of-captures is different from an array-of-arrays (at least it was a few months ago), and the array assignment flattens a capture-of-captures into a flat array. If you want to preserve the capture structure, use my @@stuff = gather ... ... but rakudo doesn't seem to support

Re: Duration of a flip-flop's flippy thing

2009-09-16 Thread yary
Sounds like a spectest is in order to prevent that case from happening, didn't see one in http://perlcabal.org/syn/S03.html (not that that's the definitive place to look for tests, but that's why I'm posting instead of DIY) However, I can well imagine an implementation botching the cloning of

Re: Severe performance loss, comparing with perl 5

2010-06-13 Thread yary
2010/6/13 Richard Hainsworth rich...@rusrating.ru: ... Your revcom can be replaced with a single line using core perl6 functions. I'll give an example that currently works on rakudo for a simple string, but you can put it into the loop. start example my

Re: Something wrong with str.reverse

2010-06-21 Thread yary
Warning on using any list-y op on a scalar seems like a good idea, and the fact that the idea arose after a perl5 misunderstanding now looks like a red herring. That is, while warning on only reverse-on-a-scalar may be a bad idea and perl5 specific, I'd vote for warning on all apparent mis-uses of

Re: very basic type checking

2010-06-24 Thread yary
On Thu, Jun 24, 2010 at 12:08 AM, Jan Ingvoldstad frett...@gmail.comwrote: On Wed, Jun 23, 2010 at 20:21, Darren Duncan dar...@darrenduncan.net wrote: If all invocations of myop use a code literal for the $y argument, then this can be checked at compile time, but if the argument is a

Re: Perl 6 Class Questions

2010-09-18 Thread yary
bikeshead return round 1 + rand * $!sides; Might be good to refer to http://perlcabal.org/syn/S32/Containers.html for a more idiomatic way of picking an integer, eg return (1..$sides).pick A roll method was just added, though I don't think its implemented yet. If you're only getting one

Re: Production Ready Perl 6?

2011-11-23 Thread yary
On Wed, Nov 23, 2011 at 9:34 AM, Wendell wendell_hatc...@comcast.net wrote: ... How do I remove myself from this user mail listing ... It's in the headers- List-Unsubscribe: mailto:perl6-users-unsubscr...@perl.org send an email to that address from the account you've subscribed with

Re: say vs print for .WHAT

2012-06-28 Thread yary
May I also take this opportunity to ask someone to explain to me what exactly are the differences between say and print? Might be that say calls .gist whereas print stringifies?

Re: Not catching an typo.

2013-12-05 Thread yary
does :b(2) :c(3) mean a pair ':b(2)' with an adverb ':c(3)'? If so I agree it's a big potential opportunity for mistakes. -y On Thu, Dec 5, 2013 at 10:01 AM, Richard Hainsworth rich...@rusrating.ru wrote: A difficult bug in a program led to the problem below. I am not sure if it is a bug in

Re: Perl 6 Debugging

2015-03-14 Thread yary
For some reason your github link comes up as an empty page when I click on it. I was able to find it here: https://gist.github.com/search?q=test_ellipsoid.pl -y

Re: Can a user cheat and call a class's private method?

2015-03-27 Thread yary
On Fri, Mar 27, 2015 at 8:35 AM, Tom Browder tom.brow...@gmail.com wrote: Use a separate module (but included with the code for the whole package) for the non-class-specific, formerly-private methods to be public, because some of the private methods are really general math subroutines.

Re: Sub args: choose one of two?

2015-07-01 Thread yary
Thanks, I missed making the named arguments required in my initial example. What I thought was a less than awesome error was perfectly appropriate; with the named arguments being optional, no arguments meant the first MAIN ran and tried printing its uninitialized parameter. -y On Wed, Jul 1,

Re: Problem with string index for substrings a position zero (a bug?)

2015-07-03 Thread yary
On Fri, Jul 3, 2015 at 8:07 AM, Tom Browder tom.brow...@gmail.com wrote: if $idx { $str = $str.substr(0, $idx); } if defined $idx { $str = $str.substr(0, $idx); } -y

Re: Passing a hash to a subroutine: best method?

2015-07-03 Thread yary
On Fri, Jul 3, 2015 at 3:03 PM, Timo Paulssen t...@wakelift.de wrote: but this does not sub takes_int_array(Int @bar) { say @bar } takes_int_array([1, 2, 3]) because the type match is against the defined type. We do not automatically infer that [1, 2, 3] could be a Positional[Int]. How

Re: Sub args: choose one of two?

2015-06-27 Thread yary
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 message is good when you give both args, but LTA with no args. # Require either named arg need or named arg hope, but not both multi sub MAIN (Int

Re: Sub args: choose one of two?

2015-07-02 Thread yary
Here's a hackish way to implement #1: #!perl6 proto MAIN (:$need, Str :$hope) { # {*} # If you want to execute the body of the multi main stubs, then uncomment this say I need $need reasons to go on if $need; say I have $hope if $hope; } multi MAIN (Int :$need!) {} multi MAIN (Str :$hope!)

Re: What are Perl 6's killer advantages over Perl 5?

2015-08-27 Thread yary
On Thu, Aug 27, 2015 at 4:45 AM, Marc Chantreux kha...@phear.org wrote: complete different usage but it would be nice to have a flag for use strict both in perl5 and 6 /me nominates -W as a bigger -w .. oh wait, -W already exists as a depreciated-in-my-view perl5 flag. In that case, I also like

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread yary
On Tue, Sep 1, 2015 at 3:10 AM, Matija Papec wrote: > Not pretty, also you'll have to take care of -a switch, S19 calls for -a and -F, surprised Rakudo doesn't have'em! Though from later examples, the ".words" method is a fine substitute. On Tue, Sep 1, 2015 at 11:03

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread yary
On Wed, Sep 2, 2015 at 12:27 PM, yary <not@gmail.com> wrote: > Do perl6's Bag type and feed operators, or other features, open up a cleaner > way? scan +spam|perl6 -e ".say for lines.map({.words(2)[1]}).Bag.sort" -y

Re: Proposed docs for C

2015-09-14 Thread yary
Keep it on separate lines, I don't know how that formatting got lost (it's showing up as separate lines in my history). As for the rest of it, curious as to consensus. -y On Mon, Sep 14, 2015 at 4:06 PM, David H. Adler <d...@pobox.com> wrote: > On Mon, Sep 14, 2015 at 03:13:21PM -0

Re: Proposed docs for C

2015-09-14 Thread yary
Using different numbers for the examples helps visualize what's initialized vs added later: sub a { *state @x = 1, 2;@x.push(3)*} =end code will continue to append each time it is called. So, =begin code say a; say "next"; say a; say "next"; say a; =end code will output =begin

Re: What are Perl 6's killer advantages over Perl 5?

2015-08-28 Thread yary
Oh dear... can we get non-strict for one liners with -E then? I admit it isn't an issue for me at the moment, as I do my one liners in perl5 currently Maybe I need to think functionally, so variable declaration isn't an issue at all -y On Fri, Aug 28, 2015 at 11:48 AM, Carl Mäsak

Gather/take & return, PHP7-style

2015-12-09 Thread yary
I was perusing PHP7's features, and tried some examples of their enhanced "yield" in Perl6. The first was pretty easy, the second I haven't figured out. Curious what yinz can do. Here's the first: ==php== The above example will output: 1 2 3 4 ===p6=== (Condensed) sub gen {gather {take 1;

Re: Gather/take & return, PHP7-style

2015-12-09 Thread yary
My example perl6 code is wrong (and gives the correct answer by accident); and gather/take aren't exactly coroutines although I see that someone's created a "coro/yield" module at https://github.com/marcoonroad/Coro-Simple/ I have some more reading and thinking to do...

Re: Gather/take & return, PHP7-style

2015-12-10 Thread yary
>So this is meant as some sort of "EOF" (or rather EOL) marker, right? > >Perl 6 does not do this, because there's already an EOF mechanism, and > you can use LAST phasers to execute after the final iteration, but still > inside the scope of the loop that works with the list. I admit, I do like

Re: release?

2015-12-29 Thread yary
I also was agreeing with Alex's critique of 6.c and then understanding Patrick's reply. "Semantic Versioning" and Perl 5's versioning scheme is so thoroughly ingrained in me now that 6.c looked like a pre-production release number, and I was waiting for 6.0.0. After reading the explanation, it

Re: signature to preserve @*ARGFILES ?

2015-11-29 Thread yary
The problem is in the line that builds the format string: sub record-fmt( $col ) { "\%-{ [max] @sheet[*;$col].map: *.chars }s" }; when $col eq ' ' it builds an invalid format. I don't know the proper fix, but as a workaround does t="' '" work? -y

Re: signature to preserve @*ARGFILES ?

2015-12-01 Thread yary
This variation confuses me. I expect $t to be constrained to "Str", but MAIN is letting it be a "Bool." I'm using Rakudo* from 201509, the 11 release isn't out for Windows- sub MAIN (*@*ARGS,Str :$t) { say $t.WHAT; say ":$t:" # .say for padded-cols $t, $*ARGFILES.lines.map:

Re: signature to preserve @*ARGFILES ?

2015-12-01 Thread yary
On Mon, Nov 30, 2015 at 2:56 AM, Marc Chantreux wrote: > sub MAIN (*@*ARGS,:$t) { > say "$t" > # .say for padded-cols $t, $*ARGFILES.lines.map: (*.split($t)) > } I changed your test code to better show the space, and it displays it OK. sub MAIN (*@*ARGS,:$t) { say

Re: "with" definedness check

2016-06-06 Thread yary
On Mon, Jun 6, 2016 at 3:47 PM, Brandon Allbery wrote: > But for that there is "given". I thought the whole point of "with" vs. > "given" was the definedness check. Ah yes, and that's a great feature. I forgot that "with" skips over the block when the topic is undefined, and

Re: Variant of 'with' which returns target object

2016-06-06 Thread yary
On Mon, Jun 6, 2016 at 2:12 PM, Eduardo Cavazos wrote: > > with_alt Point.new { .x = 10; } > > would return a Point. > > And this: > > (with_alt Point.new {.x = 10}; with_alt Point.new {.y = 20}) For your particular case, would it be sufficient to set the values

Re: Variant of 'with' which returns target object

2016-06-06 Thread yary
That's a nice & small answer. It does seem overkill for the gtk example... use v6; use GTK::Simple; with GTK::Simple::App.new(title => 'abc') { my $app = $_; my $button; .set-content: GTK::Simple::VBox.new( GTK::Simple::Button.new(label => 'bcd').clicked.tap({

Re: Variant of 'with' which returns target object

2016-06-06 Thread yary
On Mon, Jun 6, 2016 at 5:47 PM, yary <not@gmail.com> wrote: > GTK::Simple::Button.new(label => 'bcd').clicked. ... whoops, that should be with GTK::Simple::Button.new(label => 'bcd') { .clicked.tap({ .sensitive = False; $button.s

Re: '!' versus 'not' in boolean expression

2016-01-18 Thread yary
In Perl5, there's "&&" vs "and", "||" vs "or", "^" vs "xor", and "!" vs "not", the difference being precedence. Perhaps it's the same with Perl6...

Re: Perl 6 Advocacy Suggestion

2016-01-19 Thread yary
Good idea. Not sure if it needs to compare with Python explicitly. The message is that it's a great language for learning programming on its own; the reader can see that from the positive examples given and make any comparisons to other languages while reading. No need to give space away to any

Re: A practical benchmark shows speed challenges for Perl 6

2016-03-30 Thread yary
On Wed, Mar 30, 2016 at 3:20 PM, Elizabeth Mattijsen wrote: > Thanks for your thoughts! > > I’ve implemented $*DEFAULT-READ-ELEMS in > https://github.com/rakudo/rakudo/commit/5bd1e . > > Of course, all of this is provisional, and open for debate and bikeshedding. Thanks! And

Re: A practical benchmark shows speed challenges for Perl 6

2016-04-01 Thread yary
Actually I would characterize it as Before: The programmer had no control over the buffer size, and the user of the code had no way of adjusting the buffer to a particular system. Currently: The programmer has control over the buffer size, and the user of the code can adjust the buffer to a

Re: A practical benchmark shows speed challenges for Perl 6

2016-04-01 Thread yary
Not sure I understand the disagreement. "the correct buffer size is often per file, not per program/invocation, so a one-size-fits-all envar is the wrong approach"- if you're saying "it would be great to have the buffer size be an option to 'open'," then I agree. It would be nice to have that

Re: A practical benchmark shows speed challenges for Perl 6

2016-03-30 Thread yary
Cross-posting to the compiler group- On Wed, Mar 30, 2016 at 8:10 AM, Elizabeth Mattijsen wrote: > If you know the line endings of the file, using > IO::Handle.split($line-ending) (note the actual character, rather than a > regular expression) might help. That will read in

Re: A practical benchmark shows speed challenges for Perl 6

2016-04-02 Thread yary
I think I understand the objections to the proposed environment variable now. I'm branching Rakudo, and attempting my first ever patch, in order to make handle-specific buffer size possible. Leaving in the env var, as that still has possible use... On Apr 2, 2016 8:47 AM, "Tom Browder"

Re: can a method name contain a funny character?

2016-05-20 Thread yary
On Tue, Apr 12, 2016 at 6:12 PM, Brandon Allbery wrote: > I was explaining why some "symbols" are acceptable to the parser. Which one > is more appropriate is not my call, I was thinking about what exactly are valid identifiers in Perl6/rakudo's implementation. The docs

Re: can a method name contain a funny character?

2016-05-20 Thread yary
To be clear, I expect that "number" in "followed by zero or more word characters (alphabetic, underscore or number)" means "if Unicode thinks it's numeric, you can use it in an identifier after the first character." I don't expect that every numeric codepoint in Unicode must evaluate to number in

Re: can a method name contain a funny character?

2016-05-21 Thread yary
Thanks for the in-depth analysis. My misunderstanding was about what an identifier considers a number; I have no well-thought-out ideas on the subject of what an identifier ought to be. Having the docs mention that "number" means only characters with a Unicode Property GeneralCategory of Nd might

Re: How to properly represent c++ class hiearchy in nativecall?

2016-07-25 Thread yary
On Mon, Jul 25, 2016 at 4:07 AM, Vladimir Marek wrote: > Understood. My question is, whether there is one, or two $.vtable > Pointers allocated in this case: > class A {has $.x} > class B is A {has $.x} > B.new.perl B.new(x => Any, x => Any) makes me think there are 2

Re: reverse of .lines?

2017-02-17 Thread yary
On Fri, Feb 17, 2017 at 9:52 PM, ToddAndMargo wrote: > @Lines = $StringFullOfLineFeeds.lines @Lines = $StringFullOfLineFeeds.lines.reverse -y

Re: reverse of .lines?

2017-02-17 Thread yary
Oh, then chain join on the end: my $StringReversedLines = $StringFullOfLineFeeds.lines.reverse.join("\n") or my $StringReversedLines = $StringFullOfLineFeeds.split("\n",:v).reverse.join

Re: cifs control

2017-02-18 Thread yary
If your code will be running on Windows, then you should be able to use Perl6's native filesystem calls with UNC paths, and those can take IP addresses instead of host names eg. \\192.168.1.154\C$\Users\MiniMe\Documents

Re: per 5 converter?

2017-02-12 Thread yary
There's Rosetta Code to compare short programs in different languages. Not as handy as what you are asking for, still it is educational To try it out I started at http://rosettacode.org/wiki/Category:Perl_6 to find all the pages that have P6 examples. I chose "String Case" and then clicked on

Re: Killer Features of Perl 6

2016-08-22 Thread yary
> why anyone would migrate to Perl 6 from Perl5. In addition to the previous, some perl5-to-6-specific improvements: consistent handling of $_ means not having to look up "what (if anything) does this builtin do with a default?" NativeCall is quite simpler than XS Has an object system, so if

Re: Terminal::ANSIColor problem

2017-02-26 Thread yary
On Sun, Feb 26, 2017 at 8:21 AM, ToddAndMargo wrote: > Now what am I doing wrong? > Read the POD! use Terminal::ANSIColor; say color('bold'), "this is in bold", color('reset'); =head2 C Given a string with color names, the output produced by C

Re: Terminal::ANSIColor problem

2017-02-26 Thread yary
On Sun, Feb 26, 2017 at 7:13 AM, ToddAndMargo wrote: > Undeclared routine: > qw used at line 44 > Use any other bracketing than parens, eg qw[a b c d] or qw/a b c d/ Parens are used for calling subs/methods so qw(.. ... ...) means "call the sub named qw" Fixing

Re: for loop index question

2017-02-28 Thread yary
> my @a = ( 'g' .. 'k' ) [g h i j k] > @a.kv (0 g 1 h 2 i 3 j 4 k) > for @a.kv { say "Value $^v has index $^i" } Value g has index 0 Value h has index 1 Value i has index 2 Value j has index 3 Value k has index 4

Re: for loop index question

2017-02-28 Thread yary
Maybe using placeholder variables was a bit too much (those variables with the ^ twigil) > for @a.kv -> $k, $v { say "Value $v has index $k" } Value g has index 0 Value h has index 1 Value i has index 2 Value j has index 3 Value k has index 4

Re: Observations from a C++/Python developer that never used Perl5

2016-09-08 Thread yary
On Thu, Sep 8, 2016 at 6:41 AM, Kamil Kułaga wrote: > In perl6 default way is to not write new, BUILD or BUILDALL and also > not to write accessors. When you create object you can provide > attributes to initialize, default accessors are generated if field is > declared with

Re: subset problem

2016-09-16 Thread yary
You're using a "Map" when you want to use a "Bag" I think... when the Map has a count of 0, (elem) returns False. my Map $p .= new(.kv.reverse); # Map.new((:d(0),:f(1),:g(2))) say 'f' (elem) $p; # True say 'd' (elem) $p; # False my Bag $b .= new(); # bag(g, f, d) say 'd' (elem) $b; # True say 'f'

Re: subset problem

2016-09-16 Thread yary
It seems the variable as seen my the subset declaration is undefined. Here's a simplified example: > my $must_be='b' b > subset OneStr of Str where $_ eq $must_be; (OneStr) > my OneStr $x = 'b' Use of uninitialized value $must_be of type Any in string context I don't know if that's a bug in

Re: subset problem

2016-09-17 Thread yary
On Sat, Sep 17, 2016 at 4:21 AM, MT wrote: > Btw the following has the same problem; > > > my Hash $h = {a=>1,b=>2} > {a => 1, b => 2} > > $h:exists > True > > subset mh of Str where $h{$_}:exists > (mh) > > my mh $x = 'b' > Type check failed in assignment to $x; expected mh

Re: subset problem

2016-09-16 Thread yary
After reading the docs more, "Set" is better than "Bag" for this, since "Bag" has a count whereas "Set" is purely for membership. Having (elem) return False when the value of a Map element is 0 confuses me.

Re: perl 5?

2016-11-17 Thread yary
Addning to Jan's answer, PerlMonks is still a great place for answers on Perl5 topics (and even some Perl6) http://perlmonks.org/ > I still do not have perl 6 support on rhel 7.2 Don't know how much of an "early adopter" you want to be- if that's an option, try building Rakudo from source, so

Re: how to find libs

2017-01-12 Thread yary
I would do a web search for- image manipulation C library, and then check out the documentation of the results until you find one that has both enough documentation that you can understand how to use it, and enough functionality that you need. I would prefer a c library over C++, I imagine that

Re: Can this OR be shortened?

2017-03-25 Thread yary
On Sat, Mar 25, 2017 at 1:15 AM, ToddAndMargo wrote: > On 03/24/2017 07:45 PM, Brad Gilbert wrote: >> >> All of these should work >> >> if $Terminal ~~ /xterm/ | /linux/ {} >> if $Terminal ~~ /xterm | linux/ {} >> if $Terminal ~~ /xterm || linux/ {} >> >> Note

Re: What to do when a pattern match fails

2017-03-13 Thread yary
On Mon, Mar 13, 2017 at 6:16 PM, ToddAndMargo wrote: > So if it only catches some of them, it will still return false? There is no catching some of them- either the pattern matches and all are caught, or the pattern fails and none are caught. If you can show us an

Re: Net::SMTP attachments?

2017-03-01 Thread yary
On Wed, Mar 1, 2017 at 2:54 PM, ToddAndMargo wrote: > MIME::Lite That's the key- use MIME::Lite to build the headers and body of an email that has an attachment. Then use Net::SMTP, either the perl5 or perl6 version, to send it. SMTP knows nothing about attachments.

Re: I need the rules for qx with a pipe inside

2017-03-07 Thread yary
cc'ing the list again, since my reply has Timo's code formatted in a more readable & useful way- On Wed, Mar 8, 2017 at 1:58 AM, ToddAndMargo wrote: > Are you saying that someone could go into a module, alter the code, > then catch a root level program calling the module

Re: next

2017-06-17 Thread yary
On Fri, Jun 16, 2017 at 11:11 PM, Gabor Szabo wrote: > I probably would not say "restart" the loop. > > There is a statement for that, "redo" restarts the loop without updating the value. my $true_count = 0; loop (my $i = 1; $i < 10; $i++) { last if ++$true_count == 6; say

Re: :: question

2017-09-17 Thread yary
9: our sub Which ( What if you remove the space between Which and the paren? -y On Fri, Sep 15, 2017 at 5:39 PM, ToddAndMargo wrote: > On 09/13/2017 10:57 PM, Brandon Allbery wrote: > >> On Thu, Sep 14, 2017 at 1:48 AM, Brandon Allbery >

Re: <<>> question

2017-10-04 Thread yary
> Hi All, > I am writing up a keeper note on <<>> and such. This example > puzzles me. Why the space? It's the same as in perl5, an array interpolated in a string shows its elements with spaces in between. Your example has an array stored in $y. perl -e 'my @y=("ab",12,"xx");print "y=@x\n"'

Re: Tip: hash indexing

2017-10-04 Thread yary
> There may be a better way for the coercion. whatever... .say for %h.sort( * )

Re: chaining substitutions?

2017-09-24 Thread yary
Here's another solution: my $x="State : abc "; $x = $x.subst(/.*?" : "/, "").subst(/ " "+ /,""); say "<$x>"; # -y On Sat, Sep 23, 2017 at 3:54 PM, ToddAndMargo wrote: > >> Hi All, > >> > >> Question. Can I chain these two substitutions together? > >> > >> $

Re: Perl 6 Object Construction - General Advice

2017-10-01 Thread yary
I barely write any p6 but my impression was to avoid bless, and stick with using named arguments for object creation. Using positional parameters forces creating a "method new ..." I hadn't heard of TWEAK, thought that BUILD was for setting private attributes and other tasks the object runs to

Re: The equivalent of Moose's "around"

2017-11-14 Thread yary
Fernando, this list recently had a discussion on object creation, and all various ways the attributes are checked and set by the various stages. From that, what you want is TWEAK, or perhaps BUILD, which let you do things with the attribute values when the object is created. I leave the research

Re: The equivalent of Moose's "around"

2017-11-14 Thread yary
Ah yes, sorry! I'll wait for another answer along with you now. On Tue, Nov 14, 2017, 7:05 PM Fernando Santagata <nando.santag...@gmail.com> wrote: > Hi yary, > > BUILD and TWEAK work during the object creation time, not at the attribute > assignment time, as far as I know

Re: The equivalent of Moose's "around"

2017-11-14 Thread yary
Neat! Just read the Proxy class doc at https://docs.perl6.org/type/Proxy Instead of hooking into any accessor magic, this solution creates a Proxy object that lives inside the "a" method. Every time you use the "a" method, it generates a new Proxy object, which will either set or retrieve the $!a

Re: A s/// brain teaser to share

2018-05-04 Thread yary
$LabelStr, "\n"; $LabelStr ~~ s:g/( && ) \" / inch/; $LabelStr ~~ s| \/ <-["/]>+ \" | \" |; say $LabelStr; The root problem is that CSV is an ad-hoc format and you've received a particularly bad flavor... -y On Fri, May 4, 2018 at 6:10 A

Re: Need match character help

2018-05-20 Thread yary
PRM's suggestion was "*inverting the entire regex -- i.e., instead of matching finding things that do match, exclude the things that don't ... use !~~ or some similar logic to get the strings wanted*" which IMO is an excellent idea. Your implementation didn't take the inversion into account- try

Re: What is my sub?

2018-05-22 Thread yary
Oh this works too sub my-name-is-Sue () { say "Hi, ", &?ROUTINE.name } my-name-is-Sue; -y On Tue, May 22, 2018 at 8:59 AM, yary <not@gmail.com> wrote: > I was surprised there isn't a cleaner way to get a sub/method names, and > found https://docs.perl6.org/lan

Re: EVAL?

2018-06-13 Thread yary
Pet peeve, "$RunSpecific" with the quotes on either side is exactly the same as $RunSpecific without the quotes. Perl isn't shell. -y On Wed, Jun 13, 2018 at 12:27 PM, Brandon Allbery wrote: > Exactly what it says: eval is a code injection attack waiting to happen. > If you actually need it,

Re: odd and even

2018-05-02 Thread yary
It's all hyperbole, circular reasoning with bits hidden behind ellipsis... parboiled lexiconical sections. -y On Tue, May 1, 2018 at 10:04 PM, Brandon Allbery wrote: > On Tue, May 1, 2018 at 9:17 PM, Larry Wall wrote: >> >> On Tue, May 01, 2018 at

Re: A s/// brain teaser to share

2018-05-03 Thread yary
What you really want is to change a quote to "inch" if the quote is not at the start of the line, not preceeded by a comma, not followed by a comma, and not at the end of a line. > $LabelStr ~~ s:global|"3/4\""|3/4 inch|; But that will only fix inch when it is after 3/4 how about > $_='"6"

Re: OT: creating an icon on the task bar

2018-05-03 Thread yary
Windows? Try making a shortcut to the .pl6 file, then you can change the icon of the shortcut, and put that in the task bar. I don't remember the details but it ought to be enough to find it via web search. -y On Thu, May 3, 2018 at 8:55 PM, Todd Chester wrote: > Hi All,

Re: Junctions now being stringified as one alternative per line?

2018-02-25 Thread yary
I don't have Rakudo handy, is the answer to "how to make junctions show as Sean expects" say $junction.gist ; ? -y On Sat, Feb 24, 2018 at 7:27 PM, Timo Paulssen wrote: > I'm pretty sure you're running up against this change in rakudo: > >

Re: parsing in different modes

2018-08-01 Thread yary
Have you considered subclassing your grammar? The child inherits the rules from the parent, and an override the changed methods. Or, the parent grammar could be rules-and-common-methods-only, and then have two child grammas for "inside parens" vs "outside parens." Not sure the mechanics of

Re: is there a limit to a s/ ?

2018-08-10 Thread yary
1460 lines, at an average of say, oh, 70 characters per line, that's oh 100k or so? Sounds like a piece of cake... try it and see -y On Fri, Aug 10, 2018 at 8:16 PM, ToddAndMargo wrote: > Hi All, > > I was thinking of doing a > > $ p6 'my $x="a\nb\nc\nd\n"; say "$x\n"; $x ~~ s/ .*?c /c/; say

Re: Special token names, or my mistake

2018-08-12 Thread yary
Thanks! Timo's explanation nailed it, the problem is with the action not defining a method for "sum" so Any.sum becomes the action. The parsing works in grammar B without actions; "sum" is fine as a token name in that case. grammar B { rule TOP { } token sum { + % '+' } token int { \d+ }

Re: How do I test my substitutions?

2018-08-14 Thread yary
ic variable which is $_" -y On Tue, Aug 14, 2018 at 1:04 PM, ToddAndMargo wrote: > On 08/14/2018 08:29 AM, yary wrote: > >> Or, store the string in $_, and take advantage of less to type- >> >> perl6 -e '$_="abc"; say so /z/; say so /b/; s/c/defg/ ??

Re: parsing in different modes

2018-08-12 Thread yary
> > I am working with a grammar that I would like to have operate in two > different modes. In both modes the rules are identical, but the methods > should behave differently. ... > As an illustration (not the actual problem), say we want to proces > arithmetical expressions in two modes:

Special token names, or my mistake

2018-08-12 Thread yary
If I call a token "sum", this example gives an error. If I call it "something-else", it doesn't. I didn't expect an error in either case. What's going on? ~~ actions-test.p6 ~~ grammar A { rule TOP { } token something-else { + % '+' } token int { \d+ } } grammar B { rule TOP { }

Re: is there a limit to a s/ ?

2018-08-11 Thread yary
;;' >> >>> a >> >>> b >> >>> c >> >>> d >> >>> >> >>> >> >>> c >> >>> d >> >>> >> >>> >> >>> Except the real deal will be across 1

Re: How do I test my substitutions?

2018-08-14 Thread yary
Or, store the string in $_, and take advantage of less to type- perl6 -e '$_="abc"; say so /z/; say so /b/; s/c/defg/ ?? .say !! say "Failed!"' -y On Tue, Aug 14, 2018 at 4:17 AM, ToddAndMargo wrote: > > On 14/08/18 13:08, ToddAndMargo wrote: > >> Hi All, > >> > >> The Perl 5 guys have it

Fwd: A grammar to provide substitution

2018-08-28 Thread yary
Oops, forgot to hit "reply-all" this morning... similar answer to Laurent's with slightly different implementation. -y -- Forwarded message ----- From: yary Date: Tue, Aug 28, 2018 at 8:43 AM Subject: Re: A grammar to provide substitution this is simple enough to n

Re: Is Proxy a first class part of P6 or not?

2018-09-05 Thread yary
The M in Moose is for Metamodel, and if I wanted custom object behavior in Perl6, I would subclass it's standard metamodel and then override what needs changing eg STORE/FETCH. No idea how to do that, or it's feasiblity. Just have the impression that the point of having a metamodel is for this

Re: case insensitive "contains"?

2018-09-10 Thread yary
> say "Yes" if "2018 xJul 7" ~~ m:i/j :i ul/; you mean say "Yes" if "2018 xJul 7" ~~ m/j :i ul/; m/.../ - not m:i at the start! -y On Mon, Sep 10, 2018 at 4:54 AM, Laurent Rosenfeld via perl6-users < perl6-users@perl.org> wrote: > Hi Todd, > > you may use: > > say "Yes" if "2018 xJul 7" ~~

Re: A grammar to provide substitution

2018-08-29 Thread yary
Let's use "trans" instead of a regular expression, updating my example: sub format-string(Str:D $source, *%vars --> Str:D) { return $source.trans( [%vars.keys.map: '$(' ~ * ~ ')' ] => [%vars.values] ); } so simple! But, it does not catch missing variables... I bet we can fix

Re: how do I do this index in p6?

2018-09-11 Thread yary
"with"... with 'apple'.index('a') { say "Found at position $_" } else { "Not here" } # Found at position 0 with 'apple'.index('b') { say "Found at position $_" } else { "Not here" } # Not here -y On Tue, Sep 11, 2018 at 8:16 AM, Timo

Re: how do I do this index in p6?

2018-09-11 Thread yary
"Nil... it's a constant, so you have to use =:= to check for equality." Can you elaborate on that requirement? == works for an equality checks with numeric constants- must be more than Nil's constant-ness that makes one use =:= - perhaps that Nil doesn't numify to anything?

Re: Functions and subroutines?

2018-09-11 Thread yary
I would call them subroutines, since that's the long form of "sub" -y On Tue, Sep 11, 2018 at 3:47 AM, ToddAndMargo wrote: > Hi All, > > I use subs like ducks use water. It is about time > I learned what to properly call them. > > I come from Modula2 and Pascal (as well as bash), "functions"

Re: Functions and subroutines?

2018-09-11 Thread yary
aybe that's the word your looking for! -y On Tue, Sep 11, 2018 at 8:12 AM, yary wrote: > I would call them subroutines, since that's the long form of "sub" > > -y > > On Tue, Sep 11, 2018 at 3:47 AM, ToddAndMargo > wrote: > >> Hi All, >> >> I use

Re: Does words have a delimiter?

2018-04-14 Thread yary
What's an elegant way of asking for the last two words? I have this: 'foo bar bat'.words[*-2..*];# (bar bat) I bet it could be better... -y On Sat, Apr 14, 2018 at 3:23 AM, JJ Merelo wrote: > > > 2018-04-14 7:27 GMT+02:00 ToddAndMargo : > >> Hi

Re: Junctions now being stringified as one alternative per line?

2018-02-25 Thread yary
it, but say > doesn't declare that it handles junctions, so before it can call .gist on > what it gets, it will be handled by the auto-threader, so you'll get say, > and therefor .gist, called on everything inside the junction and the result > will be re-combined into a junction again. > >

  1   2   >