🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
lizmat . 07:42
tellable6 2023-04-18T21:54:59Z #raku <Xliff> lizmat A simple and obvious soluition. Thanks!
p6steve ^^ sure - Allomorphs are cool ... but raku (and perl5 IIRC) are both tuned to dwim that numbers are numbers and strings are strings depending on the context. So, in raku, the cmp operator as the smart comparison operator will apply <=> for numeric items and leg for string items and (my understanding from playing around) is that cmp will 'prefer' numbers to strings. So none of this mechanism needs to be surfaced if all 07:44
you want is to sort some numerics ;-)
Voldenet javascript behaviour is so much more sane: `[5, 1, 2, 25].sort()` gets turned into `[1, 2, 25, 5]` :) 08:29
m: <1 2 25 5>.map(*.Str).sort.say
camelia (1 2 25 5)
Voldenet I'm glad this expected behaviour can be emulated easily ;> 08:30
lizmat m: <1 2 25 5>.sort(~*).say # no need for map 08:33
camelia (1 2 25 5)
lizmat m: dd <1 2 25 5>.sort(~*)
camelia (IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(25, "25"), IntStr.new(5, "5")).Seq
lizmat note that this also keeps the allomorphiness
Voldenet m: <1 2 25 5>.sort(*.elems).say 08:45
camelia (1 2 25 5)
Voldenet …it produces expected result ;)
lizmat yeah, the sort is stable
Nemokosch lol 08:49
m: <1 2 25 5>.sort(*.chars).say
Raku eval (1 2 5 25)
Nemokosch ez win
uzl[m] I'd appreciate a look at this PR: github.com/Raku/doc/pull/4284/files 13:32
I've received some great feedback from 2colours and coke but I figured a few more eyes on it wouldn't hurt :-)
What's the Raku equivalent for this NodeJS code?... (full message at <libera.ems.host/_matrix/media/v3/d...3d5c1>) 13:39
It's probably worth asking in SO to add to the raku questions count :)
lizmat indeed :-) 13:40
only 39 to go to 2000 :-)
uzl[m] I'm a novice when it comes to asynchronous (and event-driven) programming so I'm sort of like trying to map concepts between languages even though I know they don't map 1-to-1 but it does help regardless 13:42
Wow that's awesome. Only a few years ago, it was in the hundreds
Btw does JJ still hang out in the chat? 13:43
lizmat no... he's easier to reach on the birdsite 13:49
ugexe i dont think there is something exactly equivalent 13:52
specifically the sending a message when it "starts" and sending a value to the "end" handler 13:53
m: my $eventEmitter = Supplier.new; my $eventConsumer = $eventEmitter.Supply; $eventConsumer.tap({ once say "started" }); $eventConsumer.tap(-> $_ { say $_ }, done => { say "ended" }); $eventEmitter.emit("start"); $eventEmitter.done()
camelia started
start
ended
ugexe thats close, but not exactly what you asked for
notable that the last bit, $eventEmitter.done() can't be $eventEmitter.done(23) 13:56
tonyo uzl[m]: raku.land/zef:tony-o/Event::Emitter 17:22
m: use Event::Emitter; 17:23
camelia ===SORRY!=== Error while compiling <tmp>
Could not find Event::Emitter in:
/home/camelia/.raku
/home/camelia/rakudo-m-inst-1/share/perl6/site
/home/camelia/rakudo-m-inst-1/share/perl6/vendor
/home/camelia/rakudo-m-inst-…
tonyo gist.github.com/tonyooooooo/8f0d8f...86b79a0d68 17:25
uzl[m]: ^
otherwise you can do what ugexe did and do the serialization in the .emit() and deserialization/routing all within a tap 17:26
ugexe i suppose it could be done a little cleaner with supply and react blocks, since i dont think it would require a `once { ... }` (just put that logic inside the react block) 17:30
tonyo the 'start' thing in that js code isn't a once equiv though, it'll get run any time something emits a `start` and not when the event emitter receives its first message or starts listening 18:21
using a class or hash would allow for the value 18:23
anton: i'm not sure how to reproduce the issue with fez you were seeing, i've tarred (in random order) and untarred it using system tar several 1000 times now with no error..do you happen to be using osx and the repo is on a network share? 18:27
same with the other two tars that were causing issues 18:28