Re: I need sorting help

2024-03-09 Thread Ralph Mellor
On Sat, Mar 9, 2024 at 7:52 PM yary wrote: > how to sort by alpha & numeric segments (b3b, a1a, c20c) => (a1a, b3b, c2c) Ahhh. D'oh. Thanks!  Now I see what was required, or at least think I do: .sort: {m:g/ \d+{make +$/} | \D+{make ~$/} /».made} That does what was meant, right? -- love,

Re: I need sorting help

2024-03-07 Thread Ralph Mellor
On Tue, Mar 5, 2024 at 7:01 AM ToddAndMargo via perl6-users wrote: > >> $ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ > >> (try .Numeric) // $_}).List)' > >> > >> Yippee! > > raku -e '.say for .sort: { .comb(/ \d+ | \D+ /).map({ > > .Int // .self }).cache };' > > Awesome! Now I have

Re: I need sorting help

2024-03-04 Thread Ralph Mellor
> @Sorted_List .= sort: *.match: / \d+ /; > ... > @Sorted_List .= sort: +*.match: / \d+ /; Or perhaps easier to understand: @Sorted_List .= sort: {m/ \d+ /.Str} vs @Sorted_List .= sort: {m/ \d+ /.Int} love, raiph

Re: I need sorting help

2024-03-04 Thread Ralph Mellor
On Sat, Mar 2, 2024 at 6:26 AM ToddAndMargo via perl6-users wrote: > > @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self > })}; In case another answer is helpful... First, a simplified sort that produces the same result as your code above: @Sorted_List .= sort:

Re: Raku IO IceDrive bug

2023-10-21 Thread Ralph Mellor
Hi again. :) Let me try again. I'll try cover things more clearly. #1 There was/is a bug in your code, or at least code that you say isn't working on your system. (It works on glot.io. See #3) ``` $WanIpFileName.IO.open(:w); spurt "$WanIpFileName", "New File Opened"; ``` These two lines

Re: Raku IO IceDrive bug

2023-10-16 Thread Ralph Mellor
> if not FileExists( $WanIpFileName ) { > $WanIpFileName.IO.open(:w); > spurt "$WanIpFileName", "New File Opened"; > } Afaik, depending on how you choose to look at things, there's a doc error (doc for `spurt` doesn't mention that it opens the file it's spurting to), and/or behavior due

Re: Raku regex assert doesn't match

2023-07-31 Thread Ralph Mellor
On Sun, Jul 30, 2023 at 5:21 AM Darren Duncan wrote: > > match this pattern initially, but > > fully declarative Do you consider `> .*` to be declarative? If so, what about: ``` my token nonquoted_alphanumeric_text { <[ A..Z _ a..z ]> <[ 0..9 A..Z _ a..z ]>* & >

Re: Undefine mixed data

2023-03-21 Thread Ralph Mellor
o next now it is deprecated, not assuming there's some big broad problem due to ignorance of Raku's design.) On Mon, Mar 20, 2023 at 10:42 PM Ralph Mellor wrote: > > Let me first summarize relevant parts of Raku's design. These are not > going to change. They've been in place for 2 decades and wo

Re: Undefine mixed data

2023-03-20 Thread Ralph Mellor
On Sat, Mar 18, 2023 at 6:28 PM Polgár Márton wrote: > > For what it's worth, I think most of these behaviors that sometimes > even contradict each other (like the "freshly undefined" array being > both .defined and .DEFINITE) are just design mistakes from a different time. There are no mistakes

Re: Undefine mixed data

2023-03-20 Thread Ralph Mellor
On Mon, Mar 20, 2023 at 10:42 PM Ralph Mellor wrote: > > * Definiteness or definedness? If you want it indefinite (or undefined), > call `.WHAT` on the argument. That should be "Bind the result of `.WHAT` called on the argument". Similarly: > * Truthiness? Want a fres

Re: Undefine mixed data

2023-03-20 Thread Ralph Mellor
On Mon, Mar 20, 2023 at 12:49 AM rir wrote: > > I did, and do, recognize the validity of the problem of 'undefine' not > not aligning with '.defined'. But do you understand the problem I was trying to communicate? What you're writing suggests to me you know some other PL(s) that have notions of

Re: Undefine mixed data

2023-03-18 Thread Ralph Mellor
On Fri, Mar 17, 2023 at 11:11 PM rir wrote: > > Deprecating 'undefine' is just making something easy more difficult. I see a problem with `undefine`: ``` my @bar; say @bar.defined, @bar.DEFINITE; # TrueTrue undefine @bar; say @bar.defined, @bar.DEFINITE; # TrueTrue ``` I think a warning about

Re: Upcoming documentation meetings

2023-02-04 Thread Ralph Mellor
D'oh. Time for sleep. Hopefully see or hear y'all next Sat. On Sat, Feb 4, 2023 at 11:21 PM Will Coleda wrote: > > Yes, Eastern- but the time had already passed, sorry. > > On Sat, Feb 4, 2023 at 18:13 Ralph Mellor wrote: >> >> That's super short notice but if you

Re: Upcoming documentation meetings

2023-02-04 Thread Ralph Mellor
with background music to give > > feedback? > > > > On 2/2/23, Elizabeth Mattijsen wrote: > > >> On 2 Feb 2023, at 21:11, Ralph Mellor wrote: > > >> My internet is flakey when humidity is around 80%+ and the weather > > >> forecast sugges

Re: Upcoming documentation meetings

2023-02-02 Thread Ralph Mellor
On Thu, Feb 2, 2023 at 6:10 AM Bruce Gray wrote: > > On Feb 1, 2023, at 6:00 PM, Elizabeth Mattijsen wrote: > >> On 2 Feb 2023, at 00:53, Ralph Mellor wrote: > >> It required an international phone call. > > ??? I've never had to make *any* phone call to be a

Re: Upcoming documentation meetings

2023-02-01 Thread Ralph Mellor
On Tue, Jan 24, 2023 at 9:50 PM Polgár Márton wrote: > > Since there is a public Jitsi link, I don't think this would get cancelled > because of personal problems. This is my "unofficial opinion" but I > think whether the proposed dates (noon Eastern time, second > Saturday of February, March an

Re: pointer confusion

2022-12-06 Thread Ralph Mellor
On Tue, Dec 6, 2022 at 11:55 PM ToddAndMargo via perl6-users wrote: > > > Oh, I figured out the "*ppX" double pointer. > "Pointer[Pointer]". Ironically I wrote that in a comment on your SO question before any other comments or the answers were written. But it was just a wild guess. I don't

Re: Raku opens a notepad when executing a .bat

2022-12-06 Thread Ralph Mellor
Please confirm that: * Entering `ls` at the command line prompt does what it says on the tin, it does not open notepad. * A Raku program that consists of the single line `qqx 'ls'` does what it says on the tin, and does not open notepad. If those are true, then this code: ``` use lib '.';

Re: pointer confusion

2022-12-05 Thread Ralph Mellor
On Mon, Dec 5, 2022 at 10:20 PM ToddAndMargo via perl6-users wrote: > > > use NativeCall; > > my Pointer $foo .= new: 42; > > say $foo; # NativeCall::Types::Pointer<0x2a> > > print $foo; # NativeCall::Types::Pointer<5895604297984> `say` concatenates the `.gist`s of each of its arguments.

Re: When to use .new?

2022-12-05 Thread Ralph Mellor
I forgot to mention one other shortcut that is always available if you do have to use `.new` (which is the case for most types). You can write: ``` my $foo = 42; ``` The `42` on the RHS of the `=` is the shortest way to create an integer value corresponding to `42`. But you could also write: ```

Re: When to use .new?

2022-12-05 Thread Ralph Mellor
On Thu, Dec 1, 2022 at 4:28 AM ToddAndMargo via perl6-users wrote: > > Why can I get away with `my Str $x = "";` > > But I have to use .new here (an other places too) `my $ppSession = > NativeCall::Types::Pointer.new();` There are ways to write the value of some data types with minimum fuss.

Re: pointer confusion

2022-12-05 Thread Ralph Mellor
On Sat, Dec 3, 2022 at 11:44 AM ToddAndMargo via perl6-users wrote: > > I am confused I think the following is a golf of your confusion: ``` use NativeCall; my Pointer $foo .= new: 42; say $foo; # NativeCall::Types::Pointer<0x2a> print $foo; # NativeCall::Types::Pointer<5895604297984> ``` I

Re: Session ID

2022-12-05 Thread Ralph Mellor
On Mon, Dec 5, 2022 at 9:45 AM ToddAndMargo via perl6-users wrote: > > Answer 3: > https://stackoverflow.com/questions/74665162/how-do-i-assign-the-value-in-carray-that-contains-a-memory-address-to-a-poi#74674303 > > Håkon Hægland is astonishing good at this stuff. Indeed he is! If one of his

Re: Aw: Rakudo for W7?

2022-10-23 Thread Ralph Mellor
On Sun, Oct 23, 2022 at 1:18 AM ToddAndMargo via perl6-users wrote: > > Which goes back to my question. What is the last one they published that > supports Windows 7? I would say there isn't one, where "supports" is a present tense meaning. Your question is analogous to asking what is the

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 10:59 PM Joseph Polanik wrote: > > Update: ... all methods are reporting correct results. > > Thanks for the help. Good to see resolution of problems. :) Is everything now resolved or are some things still outstanding? -- love, raiph

Re: Problem defining factorial operator in .rakumod file

2022-10-13 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 4:30 AM Joseph Polanik wrote: > > > It works for me. (v2022.02) > > When I use the REPL, the results are the same. The results are the same for ALL of us, for ALL Rakudo versions. Try the program 42!; Note how the error message is the same. The results are the same for

Re: Problem defining factorial operator in .rakumod file

2022-10-13 Thread Ralph Mellor
On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik wrote: > > I am trying to define '!' as the factorial operator. The following works > in a .raku script file: > >sub postfix: ($n) is export { > when $n == 0 {return 1} > default {$n * ($n - 1)!} >} > > However when I tried to move

Re: steps of a path

2022-09-07 Thread Ralph Mellor
On Wed, Sep 7, 2022 at 1:20 AM Marc Chantreux wrote: > > Actually what I really like the most from all your answers was the fact > that I learned a lot not only about the langage but also some idoms. That sounds cool. :) I know what *I* think of when I write "idiom" in the context of

Re: steps of a path

2022-09-06 Thread Ralph Mellor
On Mon, Sep 5, 2022 at 8:07 AM Marc Chantreux wrote: > > I just played again with your solution and got the beauty of it. > > Actually: this is by far the simplest solution. Thanks. Thanks for the follow up. So I'm not going mad! :) Given that the broader picture is file/path related

Re: BEGIN {} question

2022-09-04 Thread Ralph Mellor
On Sun, Sep 4, 2022 at 5:07 AM ToddAndMargo via perl6-users wrote: > > For the fun of it, I placed a "booboo;" > > Interesting! You might like to think of `BEGIN` as a signal to the "compiler": "Please do more than just "compile" this code. Please also run it, right now, before "compiling" any

Re: steps of a path

2022-09-03 Thread Ralph Mellor
Marc Chantreux wrote: > > I got ([^1,^2,^3]) and tried to generalize it with something > more generic (using * to get the number of elements). Yeah, I was disappointed that that didn't work, and that what did was relatively ugly, which is why I didn't bother to share it. <<. raku -ne '.Str.say

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 9:50 PM Ralph Mellor wrote: > > .put for [\~] '/A/B/C' ~~ m:g { '/'? <-[/]>+ } That won't match just a slash (`/`). Maybe: .put for [\~] '/A/B/C' ~~ m:g { ('/'? <-[/]>*) } And it'll treat `/a/b` and `/a/b/` as distinct if the input string is `/a/b/`. -- raiph

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 9:50 PM Ralph Mellor wrote: > > it makes more sense to do something like Bruce or Michel's solutions. s/Michel/William/ -- raiph

Re: steps of a path

2022-09-03 Thread Ralph Mellor
On Sat, Sep 3, 2022 at 6:17 PM Marc Chantreux wrote: > > ( A B C ) to ((A) (A B) (A B C)) ? [^1,^2,^3] I could share a generalization but it's pretty ugly and I also think it makes more sense to do something like Bruce or Michel's solutions. Here's my variation: .put for [\~] '/A/B/C'

Re: Problems with defining a class

2022-08-24 Thread Ralph Mellor
cf https://github.com/rakudo/rakudo/issues/1985 On Wed, Aug 24, 2022 at 2:47 AM Kevin Pye wrote: > > Hi, > > The following fairly simple code works well: > >class A { > has num $!a is required is built; > }; > > dd A.new(a => 1e0); > > producing "A.new(a => 1e0)". > > However, if

Re: shorter way to set states in -n?

2022-07-02 Thread Ralph Mellor
On Sat, Jul 2, 2022 at 5:26 PM Marc Chantreux wrote: > > AFAIK about raku -n, I need 2 lines to setup a state with a default value Does this do what you want: BEGIN my (@o, @f) = 0 xx 3; @o.push: "ok"; say @o; ? love, raiph

Re: probably worth a bug report ?

2022-01-02 Thread Ralph Mellor
cf https://www.nntp.perl.org/group/perl.perl6.users/2021/04/msg9883.html -- love, raiph On Sun, Jan 2, 2022 at 7:35 AM Marc Chantreux wrote: > > hello rakoons, > > I got this error message > > Too few positionals passed; expected 1 argument but got 0 > in sub xxx at - line 1 >

Re: update: meta data in Pod Block

2022-01-02 Thread Ralph Mellor
On Sun, Jan 2, 2022 at 8:00 PM Richard Hainsworth wrote: > > What does not work (in that 'newkey' is not found in the 'config' part > of the Pod::Block returned by $=pod > > =head1 :key > > = :newkey I just tried that with Rakudo v2031.03 and got a compile time error for this line: = :newkey

Re: Implementation of documented POD6 behaviour

2021-12-30 Thread Ralph Mellor
On Thu, Dec 30, 2021 at 12:18 PM Richard Hainsworth wrote: > > "In the future..." > > with a footnote that it is not implemented. > > I am willing to look at the Rakudo code and create a PR to > implement this functionality. Is there any reason not to do this I recommend you take into

Re: file format extensions

2021-12-30 Thread Ralph Mellor
On Thu, Dec 30, 2021 at 11:20 AM Richard Hainsworth wrote: > > It seems to me a short page in the docs.raku.org would > be useful with the various file extensions I'm +1 for this. I'm also +1 for recommending `.rakudoc` instead of `.pod6`. At least, for documentation files related to raku; what

Re: about binary protocol porting

2021-12-29 Thread Ralph Mellor
On Wed, Dec 29, 2021 at 1:32 AM Jon Smart wrote: > > I plan to port a binary protocol client to perl6/raku. > I have zero experience on this. Where should I get started? How well do you know programming, and Raku, and is the protocol a standard one you can link to with several existing

Re: Grammar Help

2021-12-29 Thread Ralph Mellor
On Wed, Dec 29, 2021 at 5:10 PM Paul Procacci wrote: > > Ralph, > > So Ijust tried comma w/ grammar live view ... and I must say, > I'm blown away. \o/ > This really should be in the docs (it may be, but I didn't go looking for it). I just looked using googles such as:

Re: is 'use v6' still a thing?

2021-12-28 Thread Ralph Mellor
On Tue, Dec 28, 2021 at 5:00 PM Marc Chantreux wrote: > > long time ago, there was this 'use v6' line ... Does it still make sense? I think it depends. Let's first ignore Perl. Also, let's first assume your code is not visible online. Imo *not* including a language version

Re: Greeting Larry Wall: I will learn to love you new language.

2021-12-26 Thread Ralph Mellor
On Sat, Dec 25, 2021 at 4:31 PM Maneesh Sud via perl6-users wrote: > > Merry Christmas and a Happy New Year. Hi. Happy holidays to you too. > Does perl6 or moarvm run on risc-v 32-bit processors. I think a key piece is dyncall/libffi support. Googling suggests dyncall doesn't support risc-v

Re: Grammar Help

2021-12-26 Thread Ralph Mellor
On Sun, Dec 26, 2021 at 6:01 AM Paul Procacci wrote: > > Hope everyone had a Merry Christmas and takes likings to corny opening > statements. ;) I love me some corn but it's especially appropriate to share some in winter if you've got hungry mice. :) As others have noted, you need `%%`

Re: Subscripting, semicolons, and adverbs

2021-12-11 Thread Ralph Mellor
TL;DR Raku does not treat a negative index as valid. To specify the index of the last element, write `*-1`. What you're seeing is Raku trying to inform you that you are using invalid indices. On Fri, Dec 10, 2021 at 9:49 PM Sean McAfee wrote: > > @array[-1]:exists is a syntax error, even though

Re: why not raku ?

2021-11-22 Thread Ralph Mellor
On Mon, Nov 22, 2021 at 3:33 AM Clifton Wood wrote: > > It has two compelling use cases, and it's the ones that > brought me to Raku in the first place: It has compelling use cases for me too, and I agree that grammars and nativecall are both contenders. :) But, fwiw, I didn't say just

Re: why not raku ?

2021-11-21 Thread Ralph Mellor
My 2c: On Fri, Nov 19, 2021 at 9:45 AM Marc Chantreux wrote: > > > I like ruby and perl > > so do I but raku is by far my prefered interpreted langage now. Nit. It's compiled, in the same way Java or C# is compiled. Consider: ``` say 42; constant foo = die; ``` If it were interpreted, the `42`

Re: can't make from a S/// ?

2021-11-21 Thread Ralph Mellor
On Fri, Nov 19, 2021 at 8:32 AM Marc Chantreux wrote: > > [switch `($/)` signature to `($_)` and `make` to `.make:`] > > i dug around it but missed it! arggh ... I've been digging around online doc etc and spotted that this is covered on the Traps page of the official doc:

Re: can't make from a S/// ?

2021-11-18 Thread Ralph Mellor
On Fri, Nov 19, 2021 at 1:19 AM Marc Chantreux wrote: > > method col:sym ($/) { make S:g/'""'/'"'/ with ~$/ } > > Cannot assign to a readonly variable or a value > > why isn't it working? 1. Even though `S` politely leaves "the current topic" (`$_`) alone, it still generates a match

Re: junctions with given/when

2021-11-06 Thread Ralph Mellor
On Thu, Nov 4, 2021 at 7:27 PM Joseph Brenner wrote: > > Yes, thanks, I'd managed to forget that we had a go-round OK. Cool. I wasn't sure if it was the same issue (hence my aiui qualification). It's helpful to hear confirmation you consider this to be the same issue. Btw, I'd say it was not

Re: junctions with given/when

2021-11-04 Thread Ralph Mellor
On Thu, Nov 4, 2021 at 6:34 PM Ralph Mellor wrote: > > Aiui, until we listen to Larry, accept he's right, and fix Rakudo, > the results when the topic of a smart match is a Junction will > randomly depend on which version of Rakudo you're using. Further, aiui, when we do, there ma

Re: junctions with given/when

2021-11-04 Thread Ralph Mellor
Aiui, we discussed this issue in May and Larry explained that this would happen. Larry doesn't speak up much, and I realized a few months later that it seemed no one had done anything about what he had said. So I filed an issue: https://github.com/Raku/problem-solving/issues/297 Aiui, until we

Re: A nice touch

2021-10-31 Thread Ralph Mellor
On Mon, Nov 1, 2021 at 2:38 AM Ralph Mellor wrote: > > `R` reverses associativity, which is *another* way that `R` is a > nicely designed metaoperator, though this latter aspect is not > relevant to why it worked for the solution you came up with? Ah no. Of course it has to do

Re: A nice touch

2021-10-31 Thread Ralph Mellor
On Sun, Oct 31, 2021 at 6:10 PM Sean McAfee wrote: > > the main point of my message was about the R metaoperator and the > associativity of the operator it creates. OK. Fwiw this was something I didn't know, or had forgotten, and I find it delightful. The main point of *my* comment was that I

Re: A nice touch

2021-10-30 Thread Ralph Mellor
On Sat, Oct 30, 2021 at 8:38 PM Sean McAfee wrote: > > It worked! But I couldn't quite see how. > > Anyway, pretty cool! I agree it's cool, at least in a golfing sense. But is your explanation right? The *range* operator (`..`), if the rhs is less than the left, yields an empty list rather

Re: ftp client yet?

2021-10-30 Thread Ralph Mellor
Damn but I'm a sucker for punishment. :) On Sun, Oct 31, 2021 at 12:14 AM ToddAndMargo via perl6-users wrote: > > I think you misunderstand. Fwiw I think you misunderstand. If the penny doesn't begin to drop with this email I think my head will explode. Or maybe my tail. > The code I want to

Re: ftp client yet?

2021-10-30 Thread Ralph Mellor
On Sat, Oct 30, 2021 at 5:03 AM ToddAndMargo via perl6-users wrote: > > I was trying to get the whole thing in Raku. Why are you rejecting the "whole Raku" solutions that have been suggested to you in this thread? Your original questions were: * ftp client yet? * Do we have a working ftp

Re: ftp client yet?

2021-10-29 Thread Ralph Mellor
On Fri, Oct 29, 2021 at 7:11 AM ToddAndMargo via perl6-users wrote: > > Which gets back to my original question, which was > is there good FTP support from Raku yet? The answer you got from me was: 1. Install Perl's Net::FTP. 2. Write `use Net::FTP:from;` in your Raku program. In other words,

Re: ftp client yet?

2021-10-28 Thread Ralph Mellor
On Thu, Oct 28, 2021 at 7:40 PM ToddAndMargo via perl6-users wrote: > > You would not happen to know how I could directly > write to FTP myself with Raku? Yes. 1. Install a library that implements FTP. 2. Use it. > The RFC for FTP is pretty easy to follow. It's *much* easier to write a `use`

Re: ftp client yet?

2021-10-27 Thread Ralph Mellor
> On 10/25/21 22:21, Ralph Mellor wrote: > > > > You should be aiming to end up being able to write > > something like the following three line Raku program: > > > > use lib:from 'dir-where-your-new-module-is'; > > use your-new-module:from; > > RmdirA

Re: ftp client yet?

2021-10-25 Thread Ralph Mellor
> This is what the more complicated stuff I am doing. You can also use *your* Perl code in your Raku code. Just turn your Perl code into a module, making sure to make "public" whatever the module should make public, then `use` it in your Raku code. You should be aiming to end up being able to

Re: ftp client yet?

2021-10-25 Thread Ralph Mellor
On Fri, Oct 22, 2021 at 8:45 AM ToddAndMargo via perl6-users wrote: > > >> On 10/21/21 22:03, Kevin Pye wrote: > >>> > >>> Why not just use the Perl Net::FTP? > >> > >> I use that in Perl 5. > >> I am trying to divorce myself of Perl 5. Please consider not divorcing yourself from Perl stuff you

Re: I need a better regex with a literal in it

2021-10-25 Thread Ralph Mellor
> > You can put any Raku code that produces a string > > into a regex by using the syntax `$(code)`. > > > > my $x ~~ s/ Q[;";] //; > ===SORRY!=== > Unrecognized regex metacharacter ; (must be quoted to match literally) You didn't use the syntax I showed. You need to put your code (in your case

Re: I need a better regex with a literal in it

2021-10-24 Thread Ralph Mellor
> Wish I had a Q[;;;] expression inside a regex You can put any Raku code that produces a string into a regex by using the syntax `$(code)`. So this displays `True`: ``` say so Q[ / ;;; ^&%%$$ ] ~~ / $( Q[ / ;;; ^&%%$$ ] ) / ``` as does: ``` my $string = Q[ / ;;; ^&%%$$ ]; say so $string ~~

Re: intermixed types and resulting types

2021-08-30 Thread Ralph Mellor
On Sun, Aug 22, 2021 at 4:59 PM yary wrote: > > "How would you know what types are compatible for a particular operation?" > > inspecting a routine's arguments. Bingo. > The first couple candidates raise questions for me > > multi($x = 0) - how is there a single-arg candidate for an infix

Re: What's going on with "given (junction) {when (value)...}"

2021-06-04 Thread Ralph Mellor
On Wed, Jun 2, 2021 at 11:57 AM William Michels wrote: > > Hi Ralph, Both prefix/postfix 'when' look okay on my Rakudo_2020.10 install: Only postfix in 2021.03: https://replit.com/@RalphMellor/FooACCEPT-junction#main.raku

Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
Curiously, it works for postfix `when`: ``` $_ := any(4,3); {say 'postfix when'} when 3; # 3 when 3 { say 'prefix when' } # (no output) ``` -- love, raiph

Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
On Tue, Jun 1, 2021 at 4:02 AM Larry Wall wrote: > > In my opinion, the most consistent approach is to disallow any > autothreading of the argument to .ACCEPTS That sounds like a really appropriate simplification as I write this. > All those other smartmatches are sugar for .ACCEPTS, and >

Re: File::Find using a junction with exclude

2021-06-01 Thread Ralph Mellor
On Fri, May 21, 2021 at 4:36 PM Ralph Mellor wrote: > > * Things multiply. If *two* function arguments are junctions, and > each junction has, say, three elements, the function is set to be > called *six* times. That should have been *nine* times. > * The combinatio

Re: In regexes with :P5 compatibility turned-on, do embedded modifiers work?

2021-05-23 Thread Ralph Mellor
> It's looking to me like perl5's embedded pattern modifiers don't work > when used with raku's :P5 compatibility modifier... The `:P5` modifier only supports a small subset of P5 regexes. I don't think there's any champion who wishes to push it further. (There's been talk of deprecating it

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:15 PM Joseph Brenner wrote: > > Junctions continue to surprise me: That must be either that your mental model doesn't match the default design, or you're being tripped up by DWIMs, or WATs that can't be removed due to the overall DWIM of junctions (which usually work

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:12 PM Joseph Brenner wrote: > > my impression was that junctions, by design aren't supposed to be > treated as compound data structures, they're a *single* thing but > with multiple values that co-exist with each other in "superposition". That's correct. Until they're

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 3:22 AM Joseph Brenner wrote: > > > That is a large part of the beauty of the junction design. All functions > > (and thus all operators) automatically get a very useful and powerful > > junctional behavior for free. They don't even know junctions exist. > > I can see the

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
On Fri, May 21, 2021 at 9:39 PM Joseph Brenner wrote: > > Thanks, yes the actual result is certainly consistent with the > junction applied at the top level, and not internally, which is > what I was expecting. A junction passed as an argument is immediately expanded unless a function is

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
Your results are what I would expect. The hand crafted regex puts the exclusion logic in the *single* regex that's applied by the *single* call to the `find` function. The `any` value results in calling the `find` function *twice*, with 'mothera' excluded one time, and 'camel' excluded the

Re: Comparing Int and Num

2021-04-24 Thread Ralph Mellor
On Fri, Apr 16, 2021 at 7:22 AM sisyphus wrote: >> > The conversion from int to num looks sane. Sounds good. :) So presumably our early tentative conclusion of what we hope will pan out is that if one wants precise IEEE float behaviour, one uses `num` instead of `Num`. Right? > However, the

Re: slurpy hash signatures

2021-04-23 Thread Ralph Mellor
On Wed, Apr 21, 2021 at 2:17 AM Joseph Brenner wrote: > Ralph Mellor wrote: > > [ list of idioms ] > > > Learn to use the right idioms as soon as possible. > > Okay. Where's the list of preferred idioms? The list you presented. If you had or have chosen %h3 as the

Re: gather take eager syntax

2021-04-20 Thread Ralph Mellor
You've gotten a pile of great answers. :) I'll add another to the pile, but omit explanation. say % = ["foo" => "bar"], "baz" => 42; # {foo bar => baz => 42} say % = ["foo" => "bar"]; # {foo => bar} say % = ["foo" => "bar"],; # Odd number ... Only saw:

Re: slurpy hash signatures

2021-04-19 Thread Ralph Mellor
Btw, I had misunderstood ERN when, in 2018, I wrote the email message I linked in the Note section of my previous email. ERN is an intuitive sense that some movement you are initiating is in some way a mistake. For example, quoting keys of a pair. It's often unconscious, and, aiui, ignoring it

Re: slurpy hash signatures

2021-04-19 Thread Ralph Mellor
On Mon, Apr 19, 2021 at 4:03 PM Andy Bach wrote: > > Very impressive and complete explanation, thanks! Thanks for that feedback, it's very helpful. I enjoy trying to help, but it's hard to ensure I've conveyed a tone of respect for whoever I'm replying to, at the same time as trying to keep

Re: slurpy hash signatures

2021-04-18 Thread Ralph Mellor
On Sun, Apr 18, 2021 at 8:00 PM Joseph Brenner wrote: > > Before I get started here, a small point about defining hashes. > There are various ways that work: > >my %h1 = ( 'ha' => 1, 'ho' => 2, 'hum' => 3 ); >my %h2 = ( ha => 1, ho => 2, hum => 3 ); >my %h3 = ha => 1, ho => 2,

Re: Comparing Int and Num

2021-04-15 Thread Ralph Mellor
On Wed, Apr 14, 2021 at 3:10 AM sisyphus wrote: > > Is this a bug that I ought to report ? I'm not yet convinced the issues you showed are classifiable as bugs. Part of my reasoning for my conservatism is per the guidance Larry provided in the design docs. In particular, per design doc S02: >

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
One last final piece I want to add in while we prepare to document what is worth documenting in issues is what I was trying to get at in this comment: https://www.reddit.com/r/perl/comments/93dabg/perl_6_small_stuff_4_why_perl_isnt_cobol_nor/e3etgvf/ Reviewing it I think I got a couple things

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
Another thing I've bumped into in my travels: > From: Zefram > Sent: Thursday, February 18, 2016 4:08 AM > To: perl5-port...@perl.org > Subject: Re: [perl #127182] One digit short to correctly stringify a double >> To have different NVs stringify identically is surprising; to have the >> closest

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
On Thu, Apr 8, 2021 at 3:25 AM Ralph Mellor wrote: > > On Wed, Apr 7, 2021 at 2:12 PM sisyphus wrote: > > > 2) Update Issue 5013 to better reflect the current state of > > the bugginess of "%.*g" formatting. > > Yeah. I'm focusing on 5519 ("sprintf %f

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
On Thu, Apr 8, 2021 at 3:25 AM Ralph Mellor wrote: > > On Wed, Apr 7, 2021 at 2:12 PM sisyphus wrote: > > > I also stick to my view that the latter should be the default > > behaviour, as is the case with python3 > ... > I can't imagine making an exception for convert

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-07 Thread Ralph Mellor
On Wed, Apr 7, 2021 at 2:12 PM sisyphus wrote: > > I think the important flaw is raku's incapacity to convert a Num > to its exact Rat/FatRat expression. My 2c is that I agree that that needs to be addressed. I currently see that as something to first address via sprintf. Do you agree? I get

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-07 Thread Ralph Mellor
On Wed, Apr 7, 2021 at 3:29 PM Simon Proctor wrote: > > Would =~= be what you're looking for? To quote Wikipedia, "A floating-point number is a rational number". Rob wants to compare a float with its exact equivalent rational and get True if they're exactly the same and False otherwise. --

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-06 Thread Ralph Mellor
> 1/10 == 1e1 # True > > Aiui this is correct (and to me intuitive) behaviour described here: Except A) that's not what the doc says, and B) how does one compare numbers *without* infection, if that's what's going on? So it probably makes sense to ignore at least that part of my previous email.

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-06 Thread Ralph Mellor
On Tue, Apr 6, 2021 at 11:54 AM sisyphus wrote: > 1/10 == 1e1 # True Aiui this is correct (and to me intuitive) behaviour described here: https://docs.raku.org/language/numerics#Numeric_infectiousness So if there's a `Num` (float) in a numeric operation (like `==`) then any other number

Re: Objects, TWEAK and return

2021-03-22 Thread Ralph Mellor
On Mon, Mar 22, 2021 at 2:12 PM yary wrote: > > It's not good practice to use "map" for side effects only, discarding > the returned value–which happens here I agree. > Would [using `for`] also work-around the lack of sink context in TWEAK? Yes. > I think it is a cause of the unexpected

Re: Working with a regex using positional captures stored in a variable

2021-03-22 Thread Ralph Mellor
On Mon, Mar 22, 2021 at 2:50 PM yary wrote: > > how to get all nested captures worked for me ... not sure I agree with the > design I think the current flattening aspect is awkward in a couple ways: * Having to specify ``. I half like Brad's suggestion. * Having to write `.pairs` to extract

Re: Objects, TWEAK and return

2021-03-21 Thread Ralph Mellor
On Sun, Mar 21, 2021 at 9:47 PM wrote: > > Waw! :) Following your examples and suggestions, these work: > > > class { submethod TWEAK(-->Nil) { Any.map: {say 99} } }.new; > > class { submethod TWEAK { sink Any.map: {say 99} } }.new; > > class { submethod TWEAK { eager Any.map: {say 99} }

Re: Working with a regex using positional captures stored in a variable

2021-03-20 Thread Ralph Mellor
On Wed, Mar 17, 2021 at 7:17 PM William Michels via perl6-users wrote: > > ("If the first character inside is anything other than an alpha it doesn't > capture"). > It should be added to the Raku Docs ASAP. Fyi, here's how Larry Wall expressed it 15-18 years ago: > A leading alphabetic

Re: Working with a regex using positional captures stored in a variable

2021-03-19 Thread Ralph Mellor
On Fri, Mar 19, 2021 at 6:12 PM yary wrote: > > I don't know how to get the result. > DB<1> $word = qr/(\w+)/; > DB<2> $AwithB = qr/$word with $word/ > DB<3> $_ = 'Interpolating regexes with arbitrary captures is fun!' > DB<4> x /$AwithB.*is $word/ A Raku equivalent: my $word = '(\w+)'; my

Re: Working with a regex using positional captures stored in a variable

2021-03-18 Thread Ralph Mellor
On Thu, Mar 18, 2021 at 12:59 AM yary wrote: > > As it is I get same kinds of errors in the REPL, perhaps it is MacOS > with Linenoise that's mucking that up. I can confirm your new test code also works fine in both program and repl forms in 2020.12. Though obviously the case you mark as

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
> 1. The list you posted is fantastic ("If the first character inside is > anything other > than an alpha it doesn't capture"). It should be added to the Raku Docs ASAP. Not the list, right? Just the rule. (There are dozens of kinds of assertions. No one is going to remember the list.) If you

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
And when I cut/paste from the doc, the number example works too, in both script and repl. On Wed, Mar 17, 2021 at 10:33 PM Ralph Mellor wrote: > > Er, by wfm I mean it matches 「Is」 as the code suggests. > > On Wed, Mar 17, 2021 at 10:32 PM Ralph Mellor wrote: > > > >

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
Er, by wfm I mean it matches 「Is」 as the code suggests. On Wed, Mar 17, 2021 at 10:32 PM Ralph Mellor wrote: > > Works for me in Rakudo 2020.12. > > On Wed, Mar 17, 2021 at 9:33 PM yary wrote: > > > > The "Interpolation" section of the raku docs use strings a

  1   2   >