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:31 thundergnat joined
thundergnat regarding anonymous state variables; some instances where I found them useful - rosettacode.org/wiki/P-value_correction#Raku rosettacode.org/wiki/Boustrophedon...sform#Raku (and perhaps my favorite) rosettacode.org/wiki/Egyptian_divi...22_version 00:33
Yes, I am responsible for all of those. And yes, they could be regarded as horrible hacks, but /I/ like them. 00:34
00:35 thundergnat left 01:16 guifa joined 01:51 Manifest0 left 02:49 jgaz left
el gatito (** advocate) m:perl loop (my $i = 0; $i < 10; $i++) {} say $i 03:11
Raku eval 10
el gatito (** advocate) why 03:12
why it leak out of the scope
guifa good question. That is probably a bug. I don't think it should be 04:12
09:05 sivoais left 09:55 sivoais joined 10:08 snonux joined
Nemokosch I'm not sure this is a bug. In the case of if, this is definitely known and acknowledged behavior, with the advice of using pointy block syntax instead 10:19
10:25 snonux left, snonux joined 10:28 snonux left
lizmat it leaks out of scope because that's how it was intended and implemented 10:43
there are far better solutions, such as: for ^10 { ... } 10:44
or if you you need both the value *and* the index
Nemokosch fun fact: it also "leaks out" in Python 10:45
lizmat as it does in C
Nemokosch hm, are you sure about that?
lizmat m: my @a = <a b c d e f g>; for @a.kv -> $letter, $index { say "'$letter' is at index $index" }
camelia '0' is at index a
'1' is at index b
'2' is at index c
'3' is at index d
'4' is at index e
'5' is at index f
'6' is at index g
lizmat m: my @a = <a b c d e f g>; for @a.kv -> $index, $letter { say "'$letter' is at index $index" } # duh :-) 10:46
camelia 'a' is at index 0
'b' is at index 1
'c' is at index 2
'd' is at index 3
'e' is at index 4
'f' is at index 5
'g' is at index 6
Nemokosch anyway, here I'd agree that the magic behavior would be to declare a variable out of the block and tie it to the block
what annoys me more, Raku aside, is that I can't use inner variables in do-while loop conditions
which makes sense from scope hierarchy point of view but logic-wise, it often makes sense that the condition relies on something internal to the loop body 10:52
anyway, in C and related languages, the head of control structures does unify with the inner scope, meaning that "say $i" would indeed break 10:56
11:06 rantanplan joined 11:16 rantanplan left 11:19 rantanplan joined 11:20 rantanplan left 11:22 snonux joined 11:41 ab5tract joined 12:05 Manifest0 joined 17:06 gfldex left, gfldex joined 17:19 ab5tract left 19:13 rf joined 19:14 rf left 19:15 rf joined 20:13 ab5tract joined 20:55 ab5tract left 21:00 ab5tract joined 22:42 deoac joined
deoac  Given `my regex consonants { <[mrnljzsdtfvbpkcgq]>|sh|th|ch|ph };`  How would I match all non-<consonants>? 22:57
Nemokosch iirc there is no built-in negation for regex, only character groups 23:00
new-raku.finanalyst.org/language/r...tion_check 23:03
rf Hmm, i'm sure there's a way to negate a regex 23:08
m: my regex consonants { <[mrnljzsdtfvbpkcgq]>|sh|th|ch|ph }; 'abcdefg'.match(/[<consonants>-]/).say; 23:09
camelia ===SORRY!=== Error while compiling <tmp>
Unrecognized regex metacharacter - (must be quoted to match literally)
at <tmp>:1
------> |ch|ph }; 'abcdefg'.match(/[<consonants>⏏-]/).say;
expecting any of:
argument list…
Nemokosch well, last time I asked, there wasn't a way, from what I can recall 23:10
m: say 'i' ~~ / . <!{&consonants}> / 23:11
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Undeclared routine: consonants used at line 1
Nemokosch oops
m: my regex consonants { <[mrnljzsdtfvbpkcgq]>|sh|th|ch|ph }; say 'i' ~~ / . <!{&consonants}> /
Raku eval 「i」
Nemokosch might be worth playing with
bleh, this matches 'm' as well... I wonder what that "check" did, then 23:12
m: my regex consonants { <[mrnljzsdtfvbpkcgq]>|sh|th|ch|ph }; say 'i' ~~ / . <!{ $/ ~~ &consonants }> /; say 'l' ~~ / . <!{ $/ ~~ &consonants }> /; 23:14
Raku eval 「i」 Nil
Nemokosch looks kinda bizarre but seems to do something sensible
rf Yeah that is an interesting application lol
Nemokosch / . <!{ m/<consonants>/ }> / might look better, with essentially the same logic... 23:15
hoping that the right argument is passed into the check block 23:17