This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
Anton Antonov I have a sub that takes a property option. For example, `sub f($r, :$property = 'a')` and allowed properties are 'a', 'b', 'c', 'd'. Is there an easy way to make those properties become adverbs? I would like to have this to work `f(32):b`, without defining separate signatures for each alloed property values. 00:48
I have a sub that takes a property option. For example, `sub f($r, :$property = 'a')` , and allowed properties are 'a', 'b', 'c', 'd'. Is there an easy way to make those properties become adverbs? I would like to have this to work `f(32):b`, without defining separate signatures for each alloed property values. 00:49
I have a sub that takes a property option. For example, `sub f($r, :$property = 'a')` , and allowed properties are 'a', 'b', 'c', 'd'. Is there an easy way to make those properties become adverbs? I would like to have this to work `f(32):b`, without defining separate signatures for each allowed property values.
01:19 Kaiepi left 02:00 Kaiepi joined
stevied whoa, found a nifty distribution for allowing my module to get at a modules $?DISTRIBUTION variable: raku.land/github:FCO/Injector 02:06
02:14 Kaiepi left
Nemokosch is there something for padding a string with spaces? 03:08
stevied printf 03:53
Nemokosch yeah I also ended up using sprintf
hidden behind an operator 😈
stevied time for bed. been at this all day. later 03:57
Nemokosch you are in the US though, right? 03:59
05:08 archenoth left 05:09 archenoth joined
Anton Antonov I think `.fmt` can be used. 08:04
Nemokosch good to know this exists 👌 08:06
08:14 dakkar joined 08:22 frost joined
SmokeMachine stevied: Sorry, I got curious... how do you intend to use the Injector? 08:35
Nemokosch What's the status of that module, by the way? 08:41
09:13 equinox joined
equinox hi, the syntax highlighting in docs.raku.org is amazing, can i find it to use in notepad++ etc.? if so, how? 09:18
Anton Antonov Well, if you want to use VSCode (or Atom, or IntelliJ) instead of notepad++ then there are plugins... 🙂 09:37
Also for emacs and vi, I think...
<@297037173541175296> Do you know by any chance how to pad with spaces from the right? 09:39
equinox oh, thanks. i can use VSCode as well, so i searched for Raku but what i found doesn't have the highlighting as the docs.raku page. Perhaps i should look at the source code of the documentation. 09:41
Anton Antonov Take a look here: marketplace.visualstudio.com/items...-navigator 09:45
And here: www.reddit.com/r/rakulang/comments...eadcrumbs/ 09:47
SmokeMachine Nemokosch: do you mean Injector? 09:49
if is the Injector you are talking about, I've just run some tests and it seems to be working... I don't use it for several years... 10:20
Nemokosch yes yes
SmokeMachine but I was planning on using it with Red and Cro for a page I was writing... 10:21
Nemokosch What was the original motive?
SmokeMachine ☝️
Nemokosch oh 10:22
timing 😄
SmokeMachine I was also thinking on using that inside Red... but went with dynamic vars instead...
Nemokosch I wouldn't say noone uses Raku but the community is indeed tight 10:24
but this isn't completely bad
SmokeMachine I was working with a code that used injection at $DAYJOB, and I usually try to write stuff in Raku to try to understand it better... that was also the case... 10:26
Nemokosch It just happens that the "killer feature" for me is rather banal: shell scripting back and forth
SmokeMachine I plan on write a rakush when I have some time (and when I decide how it should be...) 10:27
Nemokosch 😂 10:28
SmokeMachine (I plan on having parsers for the common commands and return dats structures instead of strings...) 10:29
Nemokosch this reminds me, I still haven't dedicated time to grammars 10:30
that would be the breakthrough 10:31
in fact, sometimes we do have to compare or convert C and Pascal codes 10:32
SmokeMachine when you do a `.ls` for example it would return a RakuSH::Return::Ls that would have a list of RakuSH::Return::File and the `.gist` of that would print the usual think, but you would also be able to pipe that to a mother command that would receive the obj and do whatever it wants...
Nemokosch there's a shitload of legacy code and the version control is not great because there are many, theoretically independent but practically mutually "influential" systems 10:34
so any tools that can meaningfully compare textual sources (code mainly but also some textual database export) are golden 10:35
lizmat soon in an ecosystem near you: github.com/lizmat/App-Rak 10:37
Nemokosch seen this 👀 10:41
10:41 equinox left
SmokeMachine lizmat++ 10:42
lizmat: cool! that accepts regex and a block, right? 10:43
in addition to a string, I mean 10:45
lizmat yes 10:49
rak '/:s method << [ hyper | race ] >> /' # look for all method hyper / method race from the current directory 10:50
Morfent looks a little nicer than ugrep/ripgrep/whatever for finding raku code 10:51
Nemokosch where does it signify "current directory"? 10:53
lizmat not specifying a second argument, means current dir 10:57
rak foo /usr/src/rakudo # search for "foo" in /usr/src/rakudo
SmokeMachine I'm also having issues when installing dependencies on GitHub actions... it fails more than work... from some time to now... idk the reason...
sorry, I'm mentioning because I saw this (github.com/lizmat/App-Rak/runs/697...ocus=true) and that's also happening to Red... 10:58
lizmat SmokeMachine: that's because I hadn't release Files-Containing yet 10:59
my fault
working on its pod now
locria The description App::Rak is empty
SmokeMachine ok, that make sense in that case then... but that's happening to me with no reason... and I ask it to run again and that works... 11:00
lizmat yeah, it's not ready for release yet...
locria How did you generate readme.md? I looks like from Pod6.
lizmat App::Mi6 generates the README.md from the pod for you, unless you switch that off
locria But not quite. 11:01
stevied Mi6 is great. Dist::Zilla done right. 11:22
I'm using Injector to inject the $?DISTRIBUTION data into another module I'm writing: Distribution::Resources::Menu. 11:29
this module will allow a user to navigate and select a resource files from the command line using a menu system 11:30
see gist.github.com/sdondley/252ffff40...3e009f5dcd 11:32
here's an early snapshot of the module: 11:35
gist.github.com/sdondley/9c7620a89...fa6b8ef587
lizmat SmokeMachine I have just released the first alpha of App::Rak 11:42
going afk for most of the day now
SmokeMachine \o/ 12:17
Anton Antonov @lizmat Nice work on “App::Rak” ! [1] I will try to make “App::Rak” a target in “DSL::English::SerachEngineQueries”. [2] I am planning to do something similar in spirit — a recommender (and search engine) for the files in a directory. [3] Another related project is to do a recommender for Raku packages. (Using some of the fez-related data repositories.) 13:24
13:28 jgaz joined
kawaii If there are two modules which both provide a Type of the same name (i.e. UUID and LibUUID), how can I specify which kind I want when setting a constraint? 13:31
I was _sure_ you could do something like `my LibUUID::UUID $blah = ...` but it seems not? 13:32
13:36 frost left 13:55 Kaiepi joined
SmokeMachine lizmat: should something like this (`rak "/class \s+ <([[\w+]+ % '::'])> \s+ '{'/"`) highlight the class name only? 14:16
lizmat: is that in the plain adding a `-o` like there is in grep? 14:20
lizmat: if there is the plan, will that make <( and )> influence the result? 14:21
stevied: Sorry, I'm not sure I got what you are doing there... 14:55
Nemokosch does it work or not? 😄 14:57
SmokeMachine stevied: OK... I think I got it... on the distro you want to have the menu you bind the distro itself and then, when you inject the ResourceMenu back (or just instantiate it) you will have the distro populated with that one you bonded... is that it? 15:06
stevied yes 15:45
it does work, yes
the hard part is building the menu from list of paths. it's a little tricky 15:46
anyone have any suggestions for my question here: stackoverflow.com/questions/727036...mple-array
i wrote a recursive function to turn an array into a nested hash. it's kind of ugly though. 15:47
oh, I think I should not have the slurpy in there anymore 15:49
Nemokosch nice 🙂 15:59
by the way
I wonder if it's possible to reduce with a postcircumfix
stevied interesting
yeah, I thought of doing something like that but I had no idea how 16:00
need a way to turn `(one two three)` into `%hash<one><two><three>` 16:01
i'm sure there is a way
I wonder if eval would work 16:03
16:09 jgaz left
Nemokosch I'm not sure if the postcircumfix {} can work, mainly because of its signature 16:15
but I'm quite sure it can be replicated some way, in an infix 16:16
I don't know how to return a brand new scalar from a function 16:18
can I tell a variable that it should be exposed with the container? 16:20
better asked... can I do this without NQP? lol 16:22
stevied you might like `return 7`?
Morfent try a loop
Nemokosch I mean like %hash<foo> itself
it does expose the container, not just the value
and I definitely remember "mind-blowing" code with assignments to a function 16:24
16:26 avuserow left 16:27 avuserow joined
gfldex m: my %h; %h{||<one tow three>} = 'how to begin a concert'; dd %h; 16:32
stevied oh, wow
gfldex this may require v6.d or even v6.*
stevied so it doesn't work? 16:33
gfldex it needs `use v6.e_PREVIEW`; 16:34
stevied i discovered eval works just fine, too. but probably safer to construct it manually
Nemokosch oh yeah, I actually tried || 16:37
I think this only works with lists to some extent
*already
16:37 dakkar left
only is also true perhaps but that was because of little sleep 16:38
Nahita another recursive attempt 16:39
```
sub hhash(%h, [$first, *@rest]) {
%h{$first} = 1 and return unless @rest;
hhash((%h{$first} = {}), @rest);
}
```
stevied ok, now I'm lost. how can I merge these arrays: 16:40
```
{testing => {testing2 => {testing3 => {test.txt => 1}}}}
{testing => {testing2 => {testing3 => {test2.txt => 1}}}}
{testing => {testing5 => {test3.txt => 1}}}
```
Nemokosch are you deliberately inventing problems? 😅
stevied heh, no.
i was hoping it would be as easy as `%(|%hash1, |%hash2, |%hash3)` but apparently not 16:42
oh, I think I can avoid this anyway 16:43
16:47 jgaz joined
stackoverflow.com/a/72704382/1641112 17:20
there's the raku-ish answer
17:38 m6502 joined 17:40 jgaz left, m6502 left, jgaz joined 17:47 n1to joined 17:57 jgaz left
SmokeMachine m: use v6.e.PREVIEW; my @array = <bla ble bli>; my %hash; %hash{||@array} = 1; dd %hash 18:12
camelia Hash %hash = {:bla(${:ble(${:bli(1)})})}
Nemokosch yes yes 18:22
cool stuff
18:49 jgaz joined
locria Is there a way to install package to edit locally? 19:57
like `pip install -e package`
stevied what I do is use zef to down the package but don't install it. then I do `use lib 'path/to/downloaded/module` 20:19
there might be a better way
<@541318874767949844> ^^ 20:22
ok, here's my little challenge: www.reddit.com/r/rakulang/comments...to_a_hash/
took me all friggin' day to figure it out, embarassingly 20:24
though to be fair, I'm pretty rusty doing this kind of thing
locria Raku's sigil is pretty weird 20:32
Weirder then: `qw<a>` is Str, not List
stevied docs.raku.org/language/quoting#Word_quoting:_qw 20:36
qw is an operator
Nemokosch I've invested quite enough time to challenge @ and % so yeah...
stevied it can have different delimiters
Nemokosch I don't know if this is called an operator but it's definitely some paren prefix
locria qw<a b> is List though
Even `qw < a >` is Str
I think it's a bug 20:37
Nemokosch could be argued for, could be against
however I would be surprised if this went unnoticed all the time 20:38
actually <1> is kind of a pattern
confer hash access
also, don't forget that (1) is also an Int, not a List
so it is consistent with that behavior
stevied i think it's because lists with one element are automatically flattened 20:40
Nemokosch (1) is not a list, for example 20:41
I mean syntactically it isn't
only the empty list () can exist without commas 20:42
otherwise, it's the comma that makes the list, not the parens
the parens just help with the precedence
thjs is unlike [] however, which does make arrays 20:43
by the way, <1> is an IntStr actually 20:44
stevied i think the deal is qw<> returns a list by default. But if you have only one element in the list, it's flattened 20:46
Nemokosch I think qw<> is exactly the same as <> 20:47
stevied and qw<> expects there to be whitespace
Nemokosch just more keystrokes
like qq{} would be exactly the same as "" iirc 20:48
stevied docs says <> does some extra special stuff to coerce objects
The angle brackets quoting is like qw, but with extra feature that lets you construct allomorphs or literals of certain numbers:
Nemokosch okay, so qw<> is just <> without the extras
stevied but yeah, quoting is tricky in raku. I have to go back and read that page.
Nemokosch qqx is my friend 20:50
🤠
wamba you could do that by `classify-list` 20:59
m: <one two three>, <one two for> andthen (%).classify-list: {|$_},:as({1}), $_ andthen .duckmap: -> @a {@a.Slip} andthen .say
m: <one two three>, <one two for> andthen (%).classify-list: {|$},:as({1}), $ andthen .duckmap: -> @a {@a.Slip} andthen .say
you could do that by `classify-list` 21:01
```raku
<one two three>, <one two for>
andthen (%).classify-list: {|$_}, :as({1}), $_
andthen .duckmap: -> @a {@a.Slip}
andthen .say
```
Nemokosch Jan is back!
I saw that you use the backslash to get away from implied semicolons 21:02
lately I've been experimenting with a line terminating `andthen` style 21:03
wamba you could do that by `classify-list`
```raku
<one two three>, <one two for>
andthen (%).classify-list: {|$_}, :as({1}), $_
andthen .duckmap: -> @a {@a.Slip}\
andthen .say
```
Nemokosch what is your advice with assignments, though? 21:05
wamba <@297037173541175296> see www.youtube.com/watch?v=C-kF25fWTO8 (especially after 14:30) It is about Clojure `->>`, but you can do that with `andthen` (or `==>`) in Raku, too. 21:24
Nemokosch I've seen this presentation a little while ago 😂 21:26
My question is in particular: how to make it look good? 21:28
For lists (finally, one use for @ 😂 ), my @values <==
blah andthen
.some-method: arg andthen
.finalize;
Looks pretty good imo
For lists (finally, one use for @ 😂 ), 21:29
my @values <==
blah andthen
.some-method: arg andthen
.finalize;
But this is _very_ specific 21:30
21:32 jgaz left 21:35 n1to left
SmokeMachine locria: that expected, not a bug 21:41
m: my @a = [<a b c>, <a b C>, <a B C>]; dd @a.classify: *.<> 21:47
camelia (my Any %{Mu} = :a($(my Any %{Mu} = :B($(my Any %{Mu} = :C($[("a", "B", "C"),]))), :b($(my Any %{Mu} = :C($[("a", "b", "C"),]), :c($[("a", "b", "c"),]))))))
SmokeMachine m: my @a = [<a b c>, <a b C>, <a B C>]; say @a.classify: *.<> 21:48
camelia {a => {B => {C => [(a B C)]}, b => {C => [(a b C)], c => [(a b c)]}}}
wamba you could do that by `classify` 21:59
```raku
<one two three>, <one two for>
andthen .classify: |*, :as({1})
andthen .duckmap: -> @a {@a.Slip}\
andthen .say
```
locria Not in named argument: github.com/Raku/user-experience/issues/46 22:09
What is this classify magic? 22:13
m: 22:15
```
my @a = [<a b c>, <a b C>, <a B C>];
say @a.classify: *.<>;
say @a.classify: { (1) };
say @a.classify: { (1, 2) };
```
stevied where can I find documentation for this: `postcircumfix:<{; }>(%hash, @list) = 1;` 23:43
I don't know what `postcircumfix<{; }>` does