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. |
|||
00:55
razetime joined
|
|||
deoac | What is the meaning of `New type Stash for Int is not a mixin type` . I got this error on a `use` statement. | 01:02 | |
01:08
Kaiepi left
01:20
razetime left,
razetime joined
01:27
razetime_ joined,
razetime left
01:37
razetime_ left
01:38
razetime joined,
razetime left
|
|||
MasterDuke | deoac: that is not a usual error. what were you `use`ing? | 01:39 | |
02:22
sgrs left
02:27
frost43 joined
02:28
frost43 left
02:29
frost joined
|
|||
deoac | A module I created. The error occurs when I `use` the module in a `.rakutest` file. The module loads correctly when I `use` it in a `.rakumod` | 03:12 | |
MasterDuke | that's a bit odd. do you have a `does` or `but` somewhere in the code? | 03:44 | |
04:58
frost left
05:10
Heptite left
05:27
Kaiepi joined
07:58
discord-raku-bot left
07:59
discord-raku-bot joined
09:03
razetime joined
11:30
sgrs joined
11:37
habere-et-disper joined
|
|||
habere-et-disper | How do you get the final output of a series of rocket operators to be a Boolean value? I keep getting a sequence: | 11:52 | |
m: ( (3,2) ==> sum() ==> map { .Bool } ).WHAT | |||
camelia | ( no output ) | ||
habere-et-disper | m: say ( (3,2) ==> sum() ==> map { .Bool } ).WHAT | ||
camelia | (Seq) | ||
Nemokosch | Hello. That's because you are essentially using a map and the map produces a sequence | 11:55 | |
habere-et-disper | How does one cast to boolean with the feed operator? | 11:56 | |
Nemokosch | the feed operators are essentially for passing arguments to subroutines in a funky order | ||
so you'd most probably want a soubroutine that coerces its last argument to Bool | 11:57 | ||
one I could quickly think of from the top of my head is prefix:<?> | |||
Nahita | habere-et-disper: you can use `so()` instead of `map { .Bool }` | ||
Nemokosch | m: say ( (3,2) ==> sum() ==> prefix:<?> ).WHAT | ||
habere-et-disper | Thanks! The prefix thing is new for me. :-) | 11:58 | |
I was trying to just cast it with ?(...) | |||
Nemokosch | so() works too, indeed. I wasn't sure (still not sure tbh) if that's a subroutine or an operator in that case | 11:59 | |
prefix:<so> also works 😄 | 12:01 | ||
Nahita | there's no "case"; it's an operator | ||
Nemokosch | alas, neither the phrasing of the documentation docs.raku.org/routine/so nor the syntax analoguous to `sum` and not the prefix `?` helps on making it clear | 12:03 | |
Nahita | operators are routines too so not sure why any of that doesn't help you but not my issue | 12:07 | |
Nemokosch | not all subroutines are operators, in the other hand, and generally, operator calls aren't like subroutine calls (unless you access them with their subroutine name, which wasn't the case here) | 12:11 | |
also, `!()`, `+()`, `?()`, `~()` all fail if you substitute them in the example, you'd want to know why that is. The only thing I can think of is precedence. | 12:12 | ||
habere-et-disper | Thank you. All helpful. :-) Another one I can't see through is how to make feed operators work with expressions? Because map returns a sequence and a sequence with even one False value is True: | 12:13 | |
m: say ?(False) | |||
camelia | False | ||
habere-et-disper | m: say ?(False).Seq | ||
camelia | True | ||
habere-et-disper | m: say (3,2) ==> sum() ==> map * %% 2 ==> so() | ||
camelia | (3 2) | ||
habere-et-disper | m: (3,2) ==> sum() ==> map * %% 2 ==> so() ==> say() | 12:14 | |
camelia | True | ||
Nemokosch | what do you want to achieve? | 12:15 | |
habere-et-disper | Just trying to know if the sum is divisible by something. | 12:16 | |
Nemokosch | I think you overestimate the magic of feed operators. They really are just a funky way to pass arguments around (or push to arrays). You don't actually want to map here, you just want to evaluate a condition. | 12:17 | |
I haven't found an actually good looking use of feed operators with "lambdas" but here you go | 12:19 | ||
m: (3,2) ==> sum() ==> {$_ %% 2}() ==> say() | |||
m: (3,2) ==> sum() ==> (* %% 2)() ==> say() | 12:20 | ||
habere-et-disper | Yeah, I tried with an anonymous inline function &(...) but that fails. I forgot to add the () to invoke. THANKS! | ||
Nemokosch | part of the reason why I prefer the andthen style | 12:21 | |
m: (3, 2) andthen .sum andthen $_ %% 2 andthen .say | |||
or, if this appeals to you more: | 12:22 | ||
m: (3, 2).sum.&{$_ %% 2}.say | |||
habere-et-disper | Thank you for expounding on the alternatives. This is rather helpful to see that same thing transformed into so many different approximate equivalences. ❤︎ | 12:25 | |
Nemokosch | you're welcome 🙂 | 12:26 | |
habere-et-disper | 👍 | ||
12:57
habere-et-disper left
13:03
Nemokosch joined
13:07
Nemokosch left
13:25
Kaiepi left
13:26
Kaiepi joined
|
|||
yabobay | is any of that beginner stuff | 13:42 | |
Nemokosch | I think most of this was beginner stuff - much more so than Inline::Python, at least 😄 | 13:46 | |
deoac | MasterDuke: No, I don't use `does` or `but` at all. | 13:52 | |
yabobay | idk seems way more complicated than that | 13:56 | |
14:21
habere-et-disper joined
|
|||
Nemokosch | well this is Raku itself, not some complicated hack to inject code from completely different backend | 14:21 | |
Kaiepi | this is kind of a meme at this point | ||
Kaiepi | deoac, what about constants or BEGIN | 14:26 | |
serialization errors get gross sometimes | |||
14:44
razetime left
15:03
probiedooo joined
|
|||
probiedooo | Hi there.. I was having a long break from P5, but came about to try some Raku. Anyhow having some issues putting the pieces together catching the line-by-line output from either shell/run directly into a @list. The command is "git branch -r" and the script is entering/pulling the repos from the dir above. Hpw can I do in the most condensed way :P | 15:10 | |
Nemokosch | hello | 15:13 | |
probiedooo | I might have lost my head since P5, but I did a lot of Clearcase-interacting scripts by `ct ...` | ||
hi there! | |||
Nemokosch | I for one like the shell quotation for this, especially since there are no parameters to inject here | ||
my @branches = map &trim, qx[git branch -r].lines | 15:15 | ||
this is quite a "Perlish" way to phrase it | |||
probiedooo | whohoo:-) ..cool must test | ||
Awww.. I am standing at the root; howto combine the pre-required "cd $repo" ahead of the operation.. not a git guru.. used to stand in the repo while checking it/running commands.. but perhaps it not necessary to cd into each and every repo? | 15:21 | ||
Nemokosch | well, there is a -C flag for git to pretend you are in a given folder. Or you can execute chdir from Raku | 15:24 | |
probiedooo | hmmmm.... maybe clumpsy but... for dir() -> $d { | ||
{ | |||
# say "==== pulling $d ===="; | |||
# shell "cd $d; git pull"; | |||
my @branches = map &trim, qx[cd $d; git branch -r].lines; | |||
for @branches -> $br { | |||
say $br; | |||
} | |||
} if $d.IO.d; | |||
} | |||
ok so chdir... right! | 15:25 | ||
or -C might be best to skip the whole cd-ing | |||
15:32
Heptite joined
|
|||
probiedooo | I am getting your point: qx[git -C $d branch -r].lines won't work ($d isn't resolved), which lefts me to the chdir option instead.. | 15:33 | |
sorry for bad variable-naming:-/ .. it's still a hack you know | 15:34 | ||
This all origins from that we can't access our Bitbucket through API-calls so I thought.. well why not do it this to check repo's for feature-branches == a PR in progress | 15:36 | ||
#Nemokosch ..your help much appreciated:-D - happy friday! | 16:00 | ||
--------------------------------------------------------------------------------------------- | |||
say "...just came out grocking in my own cave, whats happening in the others"; | |||
for dir() -> $repo { | |||
{ | |||
chdir($repo); #is an absolute path! | |||
qx[git pull]; #need to check that "qx"-thing | |||
my @branches = map &trim, qx[git branch -r].lines; | |||
for @branches -> $br { | |||
say "$repo => $br" if $br ~~ /feature/; | |||
} | |||
} if $repo.IO.d; | |||
} | |||
16:00
deoac left
|
|||
probiedooo | #Nemokosch ..your help much appreciated:-D - happy friday! | 16:01 | |
--------------------------------------------------------------------------------------------- | |||
say "...just came out grocking in my own cave, whats happening in the others"; | |||
for dir() -> $repo { | |||
{ | |||
chdir($repo); #is an absolute path! | |||
qx[git pull]; #need to check that "qx"-thing | |||
my @branches = map &trim, qx[git branch -r].lines; | |||
for @branches -> $br { | |||
say "$repo => $br" if $br ~~ /feature/; | |||
} | |||
} if $repo.IO.d; | |||
} | |||
16:05
deoac joined
|
|||
deoac | Kaiepi: No `BEGIN` blocks. No `constants` either. | 16:19 | |
Kaiepi | huh | ||
deoac | I've just noticed that I only get the error when I run the `.rakutest` thru `prove6`. If I just `raku -Ilib foo.rakutest`, there is no error. | 16:20 | |
probiedooo | #Nemokosch ..your help much appreciated:-D - happy friday! | ||
--------------------------------------------------------------------------------------------- | |||
say "...just came out grocking in my own cave, whats happening in the others"; | |||
for dir() -> $repo { | |||
{ | |||
chdir($repo); #is an absolute path! | |||
qx[git pull]; #need to check that "qx"-thing | |||
my @branches = map &trim, qx[git branch -r].lines; | |||
for @branches -> $br { | |||
say "$repo => $br" if $br ~~ /feature/; | |||
} | |||
} if $repo.IO.d; | |||
} | |||
16:42
MasterDuke left
16:49
probiedooo left
16:52
camelia left,
m_athias left
16:53
m_athias joined
16:59
camelia joined
17:50
habere-et-disper left
17:53
Nemokosch joined
18:32
Nemokosch left
19:03
deoac left
19:23
sgrs left
20:55
n1to joined
21:44
habere-et-disper joined
22:03
sgrs joined
22:45
n1to left
23:39
Heptite left
|