🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | 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 8 June 2022.
jjatria melezhik: I saw that you had sent it, but I haven't had a chance to take a proper look. I'll try to look at it over the weekend 🙇 10:04
tellable6 jjatria, I'll pass your message to melezhik
SmokeMachine s/suiting/studying/ 11:34
m: use v6.e.PREVIEW; m: my @a=<a b c d>; my %h{||@a} = True; dd %h;
camelia ===SORRY!=== Error while compiling <tmp>
Invalid hash shape; type expected
at <tmp>:1
------> PREVIEW; m: my @a=<a b c d>; my %h{||@a}⏏ = True; dd %h;
expecting any of:
constraint
SmokeMachine gfldex: I think that's the way I mostly use .none... :) Good to know I was useful for something... 11:36
m: use v6.e.PREVIEW; my @a=<a b c d>; my %h{||@a} = True; dd %h; 11:38
camelia ===SORRY!=== Error while compiling <tmp>
Invalid hash shape; type expected
at <tmp>:1
------> .e.PREVIEW; my @a=<a b c d>; my %h{||@a}⏏ = True; dd %h;
expecting any of:
constraint
SmokeMachine m: use v6.e.PREVIEW; my @a=<a b c d>; (my %h){||@a} = True; dd %h 11:39
camelia Hash %h = {:a(${:b(${:c(${:d(Bool::True)})})})}
habu Hello, does Raku have fast native shaped arrays a-la-numpy? 12:55
or, better, is it straightforward to use numpy with Inline::Python 12:56
SmokeMachine lizmat: maybe that's not rak's duty but would it make sense to allow something like this? `rak --allow-json --allow-yaml '*.<bla>.defined'` and that would parse any json or yaml files and show the ones that has a `bla` key defined at the structure of the document? Maybe 2 patterns, one when the file is json/yaml and other when its not? (Sorry, I'm just asking because I just needed something like that.) 13:10
lizmat well, we already have JSON::Fast as a dependency, so handling JSON files would be trivial 13:13
hmmm
Nemokosch by the way, I suspect JSON::Fast might be still way too slow 13:14
lizmat Nemokosch: perhaps, but "rak" is not about speed, but about features :-) 13:15
tellable6 lizmat, I'll pass your message to Nemokosch
lizmat much like Raku for that matter
Nemokosch well, for rak, it would be good to keep it useful
what's the use of finding the needle in the haystack if it turned winter in the meantime 13:16
lizmat well, I keep efficiency in mind, but not at all cost 13:17
Nemokosch by the way, no, perhaps it's not JSON::Fast that is too slow
took around 10 seconds to parse a 4,5 MB JSON string
that's okay by me
well then I have no idea what Cro is doing with that request...
SmokeMachine But it would only be slower if a flag was used... 13:18
lizmat Nemokosch: if the outer part of your JSON is an array, you could use raku.land/zef:lizmat/JSON::Fast::Hyper to make things about 3x as fast 13:19
tellable6 lizmat, I'll pass your message to Nemokosch
Nemokosch I'm afraid that isn't the case 13:20
but I wonder
it takes around 10 seconds for Cro to get a response
SmokeMachine lizmat: would that also be faster for something like `{ "count": 999999999, "items": [ ... ] }`? 13:21
Nemokosch if I take the response as string and parse it with JSON::Fast, that would take an additional 10 seconds
what on earth is Cro doing that it doesn't finish in a minute 13:22
is it stuck?
SmokeMachine (with `*.items` being an array with 999999999 items (the size is just an example))
lizmat perhaps ask on #cro ?
SmokeMachine is there a #rak? or should I keep asking/suggesting stuff about oak here? 13:23
s/oak/rak/ 13:24
lizmat there's no #rak, but maybe there should be a #raku-rak ?
but I'm happy with rak being mentioned here :-)
for now, anyway
SmokeMachine :)
SmokeMachine now I thought about auto-parsing json I am think if something like auto-parsing Raku would be useful, but someday it would be cool to search by RakuAST... (probably that should be a different tool...) 13:27
lizmat fwiw, I intend rak to be a customizable swiss-army knife :-) 13:35
SmokeMachine lizmat: so, searching by Raku's (and maybe other languages) AST is an option? 15:30
SmokeMachine lizmat: could/should it have different treats/plugins for each file type? 15:38
lizmat: should the block needle be able to receive an IO::Path instead of the content of the file? (or maybe something like IO::Path but also with the content, maybe the content as a Supply, something like node's vinyl-file (github.com/gulpjs/vinyl)) 15:42
that way you could also use the file name to filter 15:43
maybe the object representing the file could have a `.parsed` method that would return a data structure that would be the file content parsed if that's a json (for example)...that way, my first suggestion from today could be written like: `rak --allow-json --allow-yaml '*.?parsed.<bla>.defined'` 15:46
`rak --allow-json --allow-yaml '*.parsed andthen .<bla>.defined' 15:47
lizmat: (sorry for keep talking, but I got exited...) 15:49
excited 16:01
[Coke] fast way to find if dupes in a list of no more than 25 items? I am doing .sort.unique.elems == $original_length 16:18
SmokeMachine m: say so <a b c a d e f>.Bag.values.any > 1 16:23
camelia True
SmokeMachine m: say so <a b c a d e f>.Bag.values.max > 1 16:24
camelia True
SmokeMachine m: say so <a b c a d e f>.repeated 16:27
camelia True
Nemokosch repeated 💪 16:28
SmokeMachine [Coke]: hy are you sort()ing before unique()ing? You need that for squish() but not for unique(), right? 16:30
[Coke] m: my @a=<1 3 2 3>. dd @a.unique 16:32
camelia ===SORRY!=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> my @a=<1 3 2 3>. dd⏏ @a.unique
expecting any of:
infix
infix stopper
postfix
statement end
stat…
[Coke] m: my @a=<1 3 2 3>; dd @a.unique
camelia (IntStr.new(1, "1"), IntStr.new(3, "3"), IntStr.new(2, "2")).Seq
[Coke] ... habit, I guess. Thank you. :) 16:33
SmokeMachine m: .repeated.so.say for [<a e I o u>, <a e I o u a>, <a a e I o u>] 16:34
camelia False
True
True
Voldenet not sure if using .repeated is the fastest way 16:36
m: sub has-duplicates { my $h = SetHash.new(); for @^a { return True if $h.EXISTS-KEY($_); $h.set($_) }; False }; .&has-duplicates.say for [<a e I o u>, <a e I o u a>, <a a e I o u>]; 16:37
camelia False
True
True
Voldenet m: sub has-duplicates { my $h = SetHash.new(); for @^a { return True if $h{$_}; $h.set($_) }; False }; .&has-duplicates.say for [<a e I o u>, <a e I o u a>, <a a e I o u>]; 16:38
camelia False
True
True
Nemokosch it would be pretty bizarre if it isn't, that's for sure though
SmokeMachine .repeated returns a Seq, so I suppose when converting to Bool it would return on the first repeated found... but I haven't read the code yet... 16:39
Nemokosch Oh right, there was a conversion 16:40
Then it's quite possible that calculating the bool value eagerly is faster; not sure if these conversions are implemented effectively 16:42
Voldenet I'm sure the above can be rewritten with nqp::hash 16:43
SmokeMachine usercontent.irccloud-cdn.com/file/...2%402x.png 16:47
Voldenet SetHash doesn't seem efficient enough compared to nqp::hash 16:48
though practically you're testing against the worst case 16:49
SmokeMachine I think this is it: github.com/rakudo/rakudo/blob/af31...1950-L1960
yes, I'm testing over the worst case...
s/over/against/
usercontent.irccloud-cdn.com/file/...6%402x.png 16:52
Voldenet .repeated.so will shortcircuit too, so to beat it by anything one would have to copy the code of pull-one and optimize it for returning bool 16:57
SmokeMachine I think so...
But I think `.repeated.so` is fast enough... 16:59
Nemokosch nice 17:03
SmokeMachine just out of curiosity: usercontent.irccloud-cdn.com/file/...5%402x.png 17:07
lizmat SmokeMachine: to see whether a key exists in a JSON file, wouldn'r '"keyname":' suffice ? 21:17
% rak '"depends":' META6.json
META6.json
8:"depends": [
saint- Hey, I was wondering why as part of a Grammar, this works: token sentRefEnd { <char>+? <endPunc> <ref> } but not this: token sentFrag { <char>+? } 22:16
token sentRefEnd { <sentFrag> <endPunc> <ref> }
In other words, I replace the <char>+? with another token, sentFrag, and then it doesn't work for whatever reason 22:17
Nemokosch I wonder what happens if you use `regex` instead of `token` 22:20
SmokeMachine lizmat: no, because it also can be a value… 22:34
And it can be oddly idented 22:35
SmokeMachine And maybe you need something like: `rak —allow-json ‘*.parsed andthen.<bla> ~~ [**, “specific value”, **]’ 22:38
m: say <bla ble bli blo blu> ~~ [**, “bli”. **] 22:39
camelia ===SORRY!=== Error while compiling <tmp>
Unsupported use of . to concatenate strings. In Raku please use: ~.
at <tmp>:1
------> say <bla ble bli blo blu> ~~ [**, “bli”.⏏ **]
SmokeMachine m: say <bla ble bli blo blu> ~~ [**, “bli”, **] 22:39
camelia True
SmokeMachine m: say <bla ble bli blo blu> ~~ [**, “bla”, **] 22:40
camelia True
SmokeMachine m: say <bla ble bli blo blu> ~~ [**, “blu”, **]
camelia True
SmokeMachine lizmat: keyname could also be on a path different from the one you want it… matching that would get every time that was used as key… and that may not be what you want… 22:56
saint- Could anyone tell me why this code doesn't work (but the commented line works) www.toptal.com/developers/hastebin...properties 23:38