elcaro_ | Yeah... oh well. | 00:00 | |
guifa | (also, has anyone actually used R? I feel like I use Z and X a lot, but never R) | 00:02 | |
elcaro_ | I don't think I've ever used it. I think it's use is mainly for tacit code. Haskell has a `flip` function, and array languages (APL, J, etc) make extensive use of flipping arg order due to the way you write code | 00:08 | |
So I can imagine a use-case in Raku could be something like (...).map(* R- *) | 00:10 | ||
How many times have you used round-robin. I think I've only used it 2-3 times... but it's benefit is that it's a hassle to implement yourself | 00:13 | ||
I actually came across that .sort(:k) bug implementing a round-robin-ish thing I've done in array langs before | 00:16 | ||
for example, in J: (/:&; i.@#&.>) 'ABC';'12345';'wxyz' returns 'A1wB2xC3y4z5' | 00:18 | ||
rough raku translation: sub rr(+@a) { @a.map(|*)[ sort(:k, @a.map({ |[^.elems] })) ] } | |||
m: say {@^a.map(|*)[sort(:k,@a.map: {|[^.elems]})]}([<A B C>,<1 2 3 4 5>,< w x y z>]) | 00:20 | ||
camelia | (A 1 w B 2 x C 3 y 4 z 5) | ||
guifa | Yeah, I guess for me Z X RR are all if not non-trivial, certainly verbose in writing out, whereas * R- * I could just rewrite as {$^b - $^a} which doesn't interrupt the flow much | 00:29 | |
but obviously that's a style thing | 00:30 | ||
00:32
elcaro_ is now known as elcaro
00:52
Sgeo left,
Xliff left
|
|||
antononcube | @guifa I use R a lot -- it is really arcane. | 00:55 | |
The actual Raku R operator, not so much. I think the closest to it I have used a few times is ... ==> my $someVar. | 00:56 | ||
00:56
Sgeo joined
01:33
MasterDuke joined
01:43
hulk joined
01:44
kylese left
02:15
hulk left,
kylese joined
02:31
eseyman left
02:32
manu_ joined
03:08
manu_ is now known as eseyman
03:30
tejr left
|
|||
librasteve | i think single capital latin character is the way to go for round robin … maybe O since it is round? | 03:44 | |
tellable6 | 2024-10-14T23:34:19Z #raku-dev <tbrowder> librasteve ^^^ | ||
04:13
tejr joined
04:46
Aedil joined
05:30
Sgeo left
06:34
guifa left
07:41
Chanakan left
08:16
dakkar joined
09:20
Chanakan joined
09:50
tjr joined
|
|||
antononcube | @elcaro It seems more consistent rr([<A B C>,<1 2 3 4 5>,< w x y z>]) to produce (A 1 w B 2 x C 3 y A 4 z B 5 x) . | 10:22 | |
This comes from bakground using R, though, not J or K or Q. | 10:29 | ||
@elcaro & @guifa "R for Roundrobin" -- it does not seem a good idea to me at all. Currently, R stands for a much more universal and frequently used operation. "Roundrobin" is just a "partial" Z followed by flat. | 10:33 | ||
timo | ... where's that symbol that's three parallel lines getting squeezed through a ring in the center ... | 10:38 | |
lizmat | ⌘ perhaps ? | 10:42 | |
⍟ borrowed from APL | 10:44 | ||
10:48
DarthGandalf left
10:49
DarthGandalf joined
10:56
guifa joined
11:06
ab5tract left
|
|||
antononcube | I use the n-ary circle dot operator often enough: ⨀. | 12:01 | |
Also, ⨁ and ⨂. These are used when I make functional parsers in Mathematica. They are also implemented in Raku ‘FunctionalParsers“, but I prefer the set-like operators. | 12:06 | ||
Which makes me think/ask — what would be the set-like operation for “round-robin operator”? (o), (#), (Я) ? | 12:08 | ||
Also, this one: (ЯR) . | 12:09 | ||
lizmat | set-like operation for “round-robin operator”: antononcube example? | 12:10 | |
elcaro | lizmat: I like both symbols you mentioned. Either would be preferable to ➿ | 12:21 | |
I think I like ⍟ slightly more (but that's probably because it looks nicer in the APL specific font I use) | |||
tea3po | is Enum ordered? | 12:24 | |
lizmat | if you don't specify values, then it starts from 0 and increments | 12:26 | |
antononcube | @lizmat Here is an example if using set-like operations for parsers: my &p = (&p1 (|) &p2 (|) &p3 (|) &p4) (&) (&pM (^) {10**6}) (&) &pTh; &p('three million things'.words.List).head.tail; | 12:33 | |
Similarly, for "round robin" it can be : <A B C> (R) <1 2 3 3 5> (R) <w x y z> | 12:34 | ||
12:34
DarthGandalf left
12:35
DarthGandalf joined
|
|||
Or whatever other variant of (R) -- (O), (Я), etc. | 12:35 | ||
Again, I do not see built-in "round robin" operator should exist -- if that is being discussed. The "round robin" examples I have seen so far are "just" thread-like operator application. | 12:37 | ||
The way I see Z can be modified to handle that. So the "round robin" functionality can be obtained with, say: (<A B C> Z' <1 2 3 3 5> Z' <w x y z>).flat | 12:39 | ||
Where Z' stands for "partial zip." I gave an example of "completion zip" above. | 12:40 | ||
_elcaro_ | So you're saying... create a "round robin" operator, but call it something like Z′? A rose by any other name... | 12:47 | |
Meta-op's can't take adverbs, so I don't think Z can be modified to handle this case, so if it is to be an op, it needs it's own symbol. | |||
antononcube | @elcaro No, I am saying there is no need for "round robin" operator. Z already exists and has to be modified to work on lists of mismached length. Then "round robin" operation is just is just an application of that kind of Z followed by flat. | 12:52 | |
timo | what do you get when you apply .flat to Z? ... you get z if you do it half-heartedly, and _ if you do it for real | 12:54 | |
antononcube | Again -- are we talking about Raku built-in "round robin" operator? If yes, there is a more universal operation to be put in place than that. | ||
_elcaro_ | But Z's current behavior is also useful. You don't want to break it now. | 12:59 | |
FWIW, Python's zip also does the same thing >>> list(zip("ABC","12345","wxyz")) [('A', '1', 'w'), ('B', '2', 'x'), ('C', '3', 'y')] | 13:01 | ||
(then there's also itertools.zip_longest which does complete uneven lists but pads with None's) | 13:02 | ||
antononcube | @elcaro Of course, it is -- I am not suggesting to break the curent Z. 🙂 | 13:08 | |
_elcaro_ | Sorry, I misunderstood when you said "Z already exists and has to be modified ..." | ||
antononcube | The Z operator can have a "modifier" for working with lists with mistmached lengths. I do not see as breaking Z, BTW. | 13:10 | |
BTW, I do not consider Python ideas about anything as a serious argument. The most likely half-thought and half-baked. Especially, when it comes to data wrangling. | 13:11 | ||
_elcaro_ | Would you take Haskell? ghci> zip "abc" "12345" [('a','1'),('b','2'),('c','3')] ghci> zip3 "abc" "12345" "wxyz" [('a','1','w'),('b','2','x'),('c','3','y')] | 13:14 | |
antononcube | Agh, Haskell-Shmaskell -- also stupid. Promoted by Europeans. | 13:15 | |
_elcaro_ | It doesn't matter. We already agree it's behavior is useful | ||
antononcube | I am using Haskell analogies right now, BTW. (About parsing and monads.) | 13:16 | |
@elcaro Again, I am biased by using R and Mathematica for long time. In the example you give, R is going to extend the shorter lists with copies of them, Mathematica is going to fail. | 13:17 | ||
I find both of this more acceptable than the Python and Haskell results you show. | 13:18 | ||
_elcaro_ | I think APL-likes will fail. You would have to manually reshape each sub-list to the max-of-elems, then "zip" | 13:19 | |
Hmm, actually then I could just transpose and flatten ,⍉↑((⌈/≢¨)⍴¨⊢)'ABC' '12345' 'wxyz' A1wB2xC3yA4zB5w | 13:20 | ||
Ultimately it depends on the use-case which is preferred. | 13:21 | ||
The only time that immediately comes to mind of when I used round-robin was AoC 2019 Day 10. There's a monitoring station with asteroids all around it. Part 2 has you rotating a laser around in a circle destroying asteroids, and ones in front get destroyed first so that if there was an asteroid behind it, it has to wait until the next rotation... Then you need to find the position of the 200th asteroid to be | 13:25 | ||
destroyed. I grouped (classify) asteroids by angle, sorted them, and then roundrobin'd them off. In this case, I don't want the reshape behavior | |||
antononcube | There is a "precedent", sort of, with rotor : it has the adverb ":partial". I am thinking that such or similar adverb can be added zip, (To handle lists with mismatched lengths.) | 13:26 | |
_elcaro_ | I know of it (and unless you need rotors additional super-powers, .batch(n) is nicer than .rotor(n, :partial) ) | 13:29 | |
But regardless... | |||
I supposed you could give the zip routine a :partial adverb... but you can't apply adverbs to infix op's (yet?) | 13:30 | ||
From my archaic memory, meta-op's we're specifically something special in the parser, which is why users can't create them. Dunno if anything changes with rakuast | |||
antononcube | Right, that is why I was hoping to get the adverb ' to Z -- Z' to mean "handle mismatches." | 13:31 | |
_elcaro_ | Pity the syntax-highlighter maintainers that now need to handle that 😄 | 13:32 | |
You'll might have noticed in my "rose by any other name" comment, I used the PRIME symbol - not an APOSTROPHE - but (probably) no one wants to type that | 13:33 | ||
Also too confusable... people would see Z′ in some piece of code... type Z' in their own code and wonder why it doesn't work. | 13:38 | ||
antononcube | In Perl and Raku there plenty of example where small change or addition produces different results. (Or no results.) | 13:41 | |
Maybe Z... is better than Z' about hinting extensions... | 13:42 | ||
timo | m: say „oh, was?“ | ||
camelia | oh, was? | 13:43 | |
[Coke] | .seen zzzombo | 13:48 | |
tellable6 | [Coke], I saw zzzombo 2019-12-12T05:32:00Z in #raku: <ZzZombo> How do I disable autoclosing brackets in Comma? | ||
14:21
stanrifkin joined
14:48
floyza joined
15:00
ab5tract joined
16:48
dakkar left
16:50
MasterDuke left
17:10
ab5tract left
19:01
Aedil left
22:46
Sgeo joined
23:24
ab5tract joined
23:52
stanrifkin left
|