5 ms·
I just saw the code you added; here's a pretty literal translation into Raku in case you're curious (I'm assuming that `<blog posts objects>` is a stand in for
by codesections 5y ago
I just saw the code you added; here's a pretty literal translation into Raku in case you're curious (I'm assuming that `<blog posts objects>` is a stand in for omitted code)
my @arr = [blog_post_objects];
# Author may be Nil
my $author-count = +arr.map(*<author>).grep(*.defined).unique;
(Though note that this would only exclude undefined authors. In most situations, I'd probably either know that all defined authors are truthy (e.g., an object) or would want to exclude the falsy ones as well (e.g., empty string). in that case I'd use `.grep(?*)` save a few characters.)
- setpatchaddress 5y agoNot familiar with Raku, but that grep call seems like it would be quite a bit slower than the Ruby equivalent at runtime if it’s anything like a normal grep. Is there some magic there that would make that not so? Edit: clarity
- chrisoverzero 5y ago“grep” is how raku spells what is elsewhere called “filter” or “where”.