🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
codesections m: say <1 2 3>[0 .. *]; say <1 2 3>[0 .. *-0] 00:04
camelia (1 2 3)
(1 2 3 Nil)
codesections moon-child: ^^^^^
moon-child a ha! 00:05
so it's just * being magic, as usual 00:06
japhb moon-child: a bare * is just a Whatever. You get a WhateverCode when you apply certain operators to it. 01:21
sxmx anyone have an issue where raku repl doesn't show the prompt and just hangs after showing "Built on Moar..." 02:09
sxmx I am on openbsd 6.9 02:09
moon-child sxmx: it takes a long time to start up if not in cache; how long did you wait? 02:35
sxmx a minute or two, I'll give it another shot moon-child 03:13
you were right moon-child , I was just impatient 03:16
moon-child I mean in fairness, a minute or two is a pretty long time for a repl to take to start up 03:17
I think it's caching the bootfiles
(so, should be faster in the future, until the next upgrade) 03:18
sxmx This is on a VPS, and it wasn't literally a minute, more like 20 seconds 03:23
Matze37 Hello. I get stuck and like to ask for a hint. I have list of word in a file. I would like to map this list to a hash mit a key '1'. I am trying to do this in an one-liner, but i dont dig it.. 10:33
i was trying something like my %str = map(@arr.list, '1');
the array holds the list
guifa2 Matze37: what you're doing is just creating a 1 for each item in the list, and that assigns a long sequence of 1s to %str 10:50
tellable6 2021-03-18T20:53:08Z #raku <summerisle> guifa2 that did it. no clue why that didn't occur to me. this week has been cursed.
guifa2 m: say map( <a b c d>, 1 ) 10:51
camelia Cannot resolve caller map(List:D, Int:D); none of these signatures match:
(&code, +values)
in block <unit> at <tmp> line 1
guifa2 actually, ha, I guess it doesn't work at all that way
anyways
lizmat Matze37: feels to me you're creating a Set 10:52
guifa2 What you'll want is to do the map on the array.
lizmat my %str is Set = @arr
guifa2 ^^ yeah, set (or maybe ultimately a bag, if there's going to be coutning)
If you're just needing a true/false (for the word existing or not), you'll want to use a set as lizmat says. 10:53
To actually map on the array, you'll want to use a slightly different syntax.
my @arr = <a b c>; my %str = @arr.map( * => '1' ); say %str 10:54
evalable6 {a => 1, b => 1, c => 1}
Matze37 mhm 10:58
Matze37 looks like that my file is something crappy 11:00
this daid, something like that should work i guess: y %s = slurp('strings.csv').map(* => 'a'); 11:01
*my
my @arr = slurp('list.txt'); gives me [one 11:04
two
]
lizmat Matze37: if you have CSV files, you should probably be using Text::CSV ? 11:05
Matze37 i just named it so..its just a one-word list
Matze37 ok..its my slurp line..this is working well: for "list.txt".IO.lines -> $l { @arr.push: $l; } 11:07
Matze37 so the question is, how to slurp a list into  @arr? 11:09
lizmat weekly: www.edument.se/en/blog/post/comma-in-2020 11:31
notable6 lizmat, Noted! (weekly)
CIAvash Matze37: `my @arr = 'list.txt'.IO.lines;` or `my %set is Set = 'list.txt'.IO.lines;`? 11:32
guifa2 lol, "While my code style choices are obviously the correct ones, in a magnanimous moment I decided that Comma should cater better to those who feel otherwise" 11:41
xinming_ SmokeMachine: How do we pass rhs side sql value to filter? 12:18
Something like, Model.^all.grep({ .creation_time >= "(now() - Interval '1d')" })
Matze37 Well done - thank you guifa2, CIAvash! 13:34
Matze37 my %s = 'list.txt'.IO.lines.map(* => '1');  .. beautiful :) 13:43
moritz or even my %s = 'list.txt'.IO.lines X=> 1; 13:44
codesections this seems like a common practice for user-implemented custom value types (or, if not, like it should be): 14:18
m: class C { has Str $.stuff; method WHICH { ValueObjAt.new("C|{use nqp; nqp::sha1($.stuff)}")}}; say C.new(:stuff<bar>).WHICH
camelia C|62CDB7020FF920E5AA642C3D4066950DD1F01F4D
codesections is there any particular reason why we don't expose nqp::sha1 in Raku? 14:19
ugexe why would we? 14:20
codesections to encourage the idiom above. 14:21
ugexe i'm not sure use of sha1 is something to encourage 14:22
vrurg codesections: why not $.stuff.WHICH?
ugexe and the use of sha1 internally is an implementation detail that users shouldnt try to be interfacing with
moritz rakudo happens to implement some packaging stuff with certain cryptographic hashes
but if it changes that to something else, it likely won't keep a sha1 implementation around 14:23
so exposing sha1 as a public API "just because" seems wrong
codesections moritz: ? If I'm reading the source correctly, sha1 is where WHICH comes from for all non-trivial value types in Rakudo 14:24
that doesn't have anything to do with packaging 14:25
ugexe its still an implementation detail
codesections vrurg: $.stuff.WHICH returns the stringified $stuff. Which is fine for simple things, but not great for larger ones (as Raku seems to agree, based on the code) 14:27
m: Bag.new(1).WHICH
camelia ( no output )
codesections m: say Bag.new(1).WHICH
camelia Bag|A7ECAB1324EE10383A958D58A3120EBBEC860F8E
codesections ugexe: it's an implementation detail that _users_ need to implement for their types if they want them to act like built-in onse 14:29
ugexe it doesn't have to be sha1
vrurg So it seems that exposing objectid generation API would be beneficial, not sha1 in particular. 14:30
moritz agreed!
ugexe and when/if the core decides to move off sha1 we would have to keep it around because we already encouraged users to do it that way
codesections vrurg++ that's a much better idea
CodeR32 Hello 14:53
codesections o/ 14:56
jjatria Hm, I seem to be unable to install JSON::Fast:ver<0.15> at the moment 15:06
zef doesn't seem to find any candidates for that, even though it worked before. I can install 0.14, though
ugexe m: say (CompUnit::Repository::Distribution but role :: { method Str { "mystring" } }).id; # totally up to spec! 15:43
camelia 9CE3EA4D6FAC2165933B3971E6D5A13753C7D878
tonyo_ m: grammar G { rule TOP { ^ . $ }; }; role A { method TOP($/) { say $/ ~~ m/'a'/; }; }; G.parse("b", :actions(A)); 16:50
camelia Cannot assign to a readonly variable or a value
in method TOP at <tmp> line 1
in regex TOP at <tmp> line 1
in block <unit> at <tmp> line 1
summerisle is there a way to figure out at what point in a corpus of text a grammar stops matching? 16:53
tonyo_ there's grammar::tracer 16:57
you can see the steps the grammar goes through and when it stops matching
raydiak m: grammar G { rule TOP { ^ . $ }; }; role A { method TOP($m) { say $m ~~ m/'a'/; }; }; G.parse("b", :actions(A)); 18:45
camelia False
raydiak m: "b" ~~ m/^.$/; say $/ ~~ m/"a"/ 18:53
camelia True
raydiak m: "a" ~~ m/^.$/; say $/ ~~ m/"a"/
camelia 「a」
raydiak m: "b" ~~ m/^.$/; say $/.clone ~~ m/"a"/ 18:56
camelia False
summerisle so i have an action method that uses make to attach a payload to a match. i'd like to be able to inspect that payload in a later action method, but it appears to be unset 21:59
and i can verify they execute in the desired order
tonyo_ how are you trying to access the made later? 22:06
i have a toml 1.0.0 compliant grammar/action that i'm testing now, i can put somewhere if an example would help.
summerisle could be my mistake on my part. this week has been a trip. 22:10
seeing the expected behavior in other atcion methods
tonyo_ an example might help me (or others) help ya 22:12
vrurg Anyone to remind me if regexes have something to express <-[ $char ]> without string interpolation in <{ }>? 22:47
*in -> with
summerisle ok, more grammar stuff, is there a way when specifying a <token-name> within the body of another token to specify that any corresponding action method not be run? 23:01
or would i just want to create a copy of token-name without a corresponding action method 23:02
MasterDuke vrurg: istr some discussion about that a little while ago, but i don't think there was a conclusion other than what you just said 23:09
vrurg MasterDuke: thanks! I also remember the discussion existed, but otherwise nothing about it. 23:34
summerisle: I don't think so. An action method is invoked unconditionally.
summerisle yeah, i ended realising i had a bad design in that area anyways so i'm reworking it 23:35
MasterDuke vrurg: github.com/Raku/problem-solving/issues/97 23:36
vrurg MasterDuke: thanks! 23:40
MasterDuke np 23:42