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.
02:17 tea3po joined 02:20 teatwo left 04:21 Heptite left
AirwaveDev what i might be doing wrong ? even if arguments are valid it just says please enter valid arguments 06:12
cdn.discordapp.com/attachments/768...is_try.png
it just doesn't reach return 06:15
snufkin Output the values of $a,$b,$c after the prompt. See what they are. Also output $a ~~ Int etc and see what the result is 06:17
If the variables are strings, I think you can prefix them with + to coerce them to Int. 06:19
AirwaveDev yup values of variables are strings 06:21
snufkin Think you'd just need to do if +$a ~~ Int etc 06:22
AirwaveDev for some reason coercion didn't worked 06:54
so manually type casted
now the programme works just as desired
I appreciate your guidance 06:55
thank you :camelia:
cdn.discordapp.com/attachments/768...8/p_tr.png
Nemokosch I would think why the coercion didn't work 06:57
In case some misunderstanding is lurking around 06:58
Anyway, fun fact: $a = $a.Numeric can be written as $a.=Numeric 06:59
AirwaveDev Expected there would something like that 07:02
Nemokosch Also... is rw for a variable declaration seems buggy 07:06
m: my $foo is rw 07:07
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Can't use unknown trait 'is' -> 'rw' in a variable declaration. at /home/glot/main.raku:1 ------> my $foo is rw⏏<EOL> expecting any of: TypeObject default dynamic export
AirwaveDev cdn.discordapp.com/attachments/768...123430.png 07:09
Nemokosch the error happens in is-triangle 07:11
+$a doesn't mutate the original variable that you return
coercing type annotations might come handy here 07:12
AirwaveDev man you are fast
m:my $foo is rw; 07:14
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Can't use unknown trait 'is' -> 'rw' in a variable declaration. at /home/glot/main.raku:1 ------> my $foo is rw⏏; expecting any of: TypeObject default dynamic export
Nemokosch that is rw in the "destructuring" declaration is just silently ignored, from what I know
the "destructuring" declaration is currently implemented as a function signature with parts dropped when creating the variable 07:16
this came up just a couple of days ago
AirwaveDev :cameliathink:
I haven't updated
though 07:17
Nemokosch the topic
the behavior has been like this for years at the very least
AirwaveDev See ya later then 07:18
Nemokosch 👋 😄
what does work, on the other hand, is 07:19
m: my Numeric() ($a, $b, $c) = split " ", "53 22 1"; dd $a, $b, $c; 07:20
Raku eval Int $a = 53 Int $b = 22 Int $c = 1
AirwaveDev dd $a, $b, $c; what this part did ? 07:21
Nemokosch the logging
AirwaveDev I am ashamed to ask but what is that if i am bothering you please kindly ignore 07:24
Nemokosch No, I think that's why everyone is here
AirwaveDev so what is logging 07:25
Nemokosch > to make a note or record of something 07:27
that's exactly what it means, Merriam-Webster to the rescue
you wouldn't automagically see the content of the variables, something needs to be done 07:28
m: my Numeric() ($a, $b, $c) = split " ", "53 22 1";
Raku eval
Nemokosch ^ this isn't too telling, right?
AirwaveDev thanks 07:31
i should run off to next exc and topic
Nemokosch what's exc? 07:32
exercise?
AirwaveDev I am learning raku with this book called think raku 07:34
Nemokosch Mmm, heard of it 07:35
AirwaveDev yup exercise after end of each topic
Nemokosch I heard good things about that book but it can never hurt to be a bit careful 07:38
Like with the fake is rw
if you think about it, a variable is readable and writeable, that's like the definition - is rw is more interesting for function input and output stuff 07:45
07:53 dakkar joined
tea3po I think dd is data dump, or maybe describe 10:42
lizmat it's actually the tiny data dumper: so tiny it lost the "t" 10:46
it's basically "note .raku" with some extra introspection and support for some native data types 10:47
Anton Antonov 🙂 10:51
tea3po did perl5 have Data::Dumper::Dumper() or am I remembering some othe rlanguage 11:02
lizmat no, you remember that correctly 11:07
11:43 Heptite joined 13:06 jgaz joined 13:31 jgaz left 13:32 jgaz joined 14:10 Heptite left 14:12 teatwo joined 14:15 tea3po left 14:56 Heptite joined 15:54 dontknow joined 16:35 raiph joined 16:36 dakkar left 17:18 dontknow left 17:32 raiph left
Mediocre what is this? 17:48
cdn.discordapp.com/attachments/768.../image.png
why 1 has [] and other () 17:51
cdn.discordapp.com/attachments/768.../image.png
Anton Antonov Probably not very helpful, but ask ChatGPT for multiple examples of Raku junctions : 17:55
cdn.discordapp.com/attachments/768....40_PM.png
Mediocre well was not really clear 18:00
Anton Antonov 🙂 As anticipated ... 18:01
Mediocre what are those XD
cdn.discordapp.com/attachments/768.../image.png 18:02
18:03 deoac joined 18:09 deoac left
Anton Antonov backslashed character classes (for making regex patterns) 18:18
Mediocre i dunno how it would look lik ea horizontal whitepace 18:24
Anton Antonov Yes, both whitespaces and non-whitespaces. 18:25
@Mediocre I am not sure what you know about programming and regexes -- maybe my assumptions are completely wrong. 18:26
Mediocre i dont know 18:27
am learning
okay now i get it 18:28
and its a bit weird but i understood
Anton Antonov 👍 18:39
Nemokosch stuff in [] is an Array overall 21:16
stuff in () is usually just a List, here I'd think it might actually be a reified Seq 21:17
m: my @numbers = (^20).roll: 10; say @numbers.sort.WHAT; say @numbers.sort; 21:18
Raku eval (Seq) (0 3 3 6 6 7 8 9 15 18)
Nemokosch right, it's just a Seq
p6steve list assignment like @n = 1,2,3; takes a List (or Seq) on rhs and assigns each item to Array on lhs 21:24
Nemokosch this terminology with "functions" and "mutators" is kinda confusing 21:26
p6steve ^^ i agree ... it just means that @n = @n.push(1); will change @n (durrr) 21:27
21:28 deoac joined
Nemokosch of course one can give a name to the phenomenon but it feels risky to use the term "function" for that; it's too overloaded 21:28
all in all, the message is that there are many methods that don't change the object they are called on. sort is such a method 21:30
for these methods, if you want to mutate the object, you would naively write something like my-list = my-list.sort 21:31
there is a less redundant (near) equivalent for that: you can just write my-list.=sort 21:32
p6steve :cameliathink: 21:33
Mediocre i sadly understood nothing XD 22:02
Nemokosch that's kind of sad indeed 22:03
Anton Antonov It is normal.
You may fall in love with Raku, but Raku does not necessarily fall in love with you.
Nemokosch 🤣 22:05
Anton Antonov Before Raku, that was my experience with Number Theory. 22:07
Nemokosch It has been quite a while that I understood nothing 22:09
And frankly, almost always it was rather like I understood something and thought I understood 10x as much
22:19 Heptite left 22:22 jgaz left
p6steve #v1 my ($a is rw, $b is rw, $c is rw); # not needed sub call { my ($a,$b,$c) = split " ", prompt "enter: "; if +$a ~~ Int && +$b ~~ Int && +$c ~~ Int { return $a, $b, $c; } else { say "nope"; call; } } my ($a, $b, $c) = call(); # combine say($a, $b, $c); 22:33
^^^ I thought I would try to streamline a bit ... here we can remove some of the delcarations
#v2 sub call { my ($a,$b,$c) = split " ", prompt "enter: "; # use an array if +$a ~~ Int && +$b ~~ Int && +$c ~~ Int { # use a map & a junction return $a, $b, $c; # return not needed } else { say "nope"; call; # drop last ; } } say call.join(" ") 22:34
^^^ and then we can use an array and a junction to make a bit more clear 22:35
#v3 sub call { my @a = split " ", prompt "enter: "; if @a.map(+*).all { # test all for Num @a } else { say "nope"; call } } say call.join(" ")
lizmat wouldn't it make more sense to use .first and search for the first non-numeric ? 22:36
p6steve lizmat: that would be too easy 22:38
lizmat ah, ok :-)
Nemokosch > if @a.map(+*).all this is risky though
what if the value is actually 0?
p6steve err - ok it's late 22:45
#v4 sub call { my @a = split " ", prompt "enter: "; if @a.map(*.Int).all { # test all for Num @a } else { say "nope"; call } } say call.join(" ") 22:46
#test all for ability to coerce to Int ... 22:47
Nemokosch I was also thinking about this in the morning 😄 22:53
p6steve sub call { my @a = split " ", prompt "enter: "; dd @a; if @a.map({+$_ ~~ Int}).all { # test all for Num @a } else { say "nope"; call } } say call.join(" ") 22:54
ha!
g'night 22:55
Nemokosch byez
I fancy something like my Numeric() @a = ... and then @a.all ~~ Int for the check 22:56
apparently this doesn't explode even if some elements are Failure
p6steve my final offer: 23:01
sub call { my @a = split " ", prompt "enter: "; if @a.map(+*).all ~~ Int { # test all for Num @a } else { say "nope"; call } } say call.join(" ")