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:49 MasterDuke left 03:00 MasterDuke joined 04:32 MasterDuke left 06:24 CIAvash joined 06:38 CIAvash left 07:20 CIAvash joined 07:33 CIAvash left 13:08 jgaz joined
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/08/26/2024-...ro-💍-htmx/ 13:29
jgaz Shouldn't `raku -e 'say "AA".split("").elems'` agree with `raku -e 'say "AA".chars'`? The former returns `4` the later the expected `2`. 13:46
lizmat m: dd say "AA".split("") 13:50
camelia ( A A )
Bool::True
lizmat m: dd "AA".split("")
camelia ("", "A", "A", "").Seq
lizmat when you split on the empty string, there's a boundary at the start and at the end as well 13:51
if you just want the separate graphemes, use "comb"
m: dd "AA".comb
camelia ("A", "A").Seq
jgaz lizmat, What is the use case for the distinction? 13:53
lizmat
.oO( the use case is in the eye of the beholder )
13:54
jgaz Okay
lizmat but seriously: .comb will give you all graphemes, if you want to look at them
but .comb is more general 13:55
m: dd "foobarbaz".comb(3)
camelia ("foo", "bar", "baz").Seq
lizmat m: dd "foobarbaz".comb(/ (\w) $0 /) # two consecutive chars 13:56
camelia ("oo",).Seq
lizmat it all depends on what you want to achieve
where .comb focuses on the things you want to obtain, and .split focuses on where to split 13:57
jgaz Okay, I follow the difference in perspective. 13:59
I feel like an idiot for asking this, because I used to know how and it's escaping me, but how do I convert two equal length arrays into a hash? I thought it was `Z` but I can't associatively index into the results of `@a1 Z @a2`. 14:01
nahita3882 Z returns a Seq, so you cannot directly associatively-index its result. But you can zipWith => and %(...) it to get a hash from array 1 to 2 14:13
i.e., %(@a1 Z=> @a2) 14:14
also (.comb is better for sure but) there is :skip-empty for Str.split to not give you the "extra"s there, i.e., "AA".split("", :skip-empty) eqv ("A", "A").Seq holds 14:15
jgaz nahita2882, okay, so I was only so far wrong. 14:27
I'll give `Z=>` a try. 14:28
nahita3882 So far so good with `%(@a1 Z=> @a2)<foo>`. Thanks for the help. 15:05
scullucs Is there an IO::Path (or something) method to obtain file/dir permissions? 20:18
ab5tract m: “/tmp/foo”.IO.spurt(“existing”); dd “/tmp/foo”.IO.rw 20:26
camelia Bool::True
ab5tract m: “/tmp/foo”.IO.spurt(“existing”); dd “/tmp/foo”.IO.mode 20:27
camelia IntStr.new(420, "0644")
ab5tract ^^ scullucs
scullucs Dang! Some days I'm more stupid than usual. A simple search for "permission" in the IO::Path doc page (which I was skimming) would have found it. 20:31
Thanks 🙂
ab5tract Not to worry. I find that allomorph interesting.. +420, ~”0644” 20:35
librasteve The mode is correct. 644 is an octal representation, which is 420 in decimal. <=== just found this by googling ... didn't realise that modes are octal en.wikipedia.org/wiki/File-system_...c_notation 20:39
scullucs They're usually represented in octal to make them easier to read. 20:40
*to interpret.
ab5tract Ah, yeah that makes sense. Forgot that about octal
But it makes 0777 as max permissions make sense 20:41
librasteve maybe there is a better allomorph like `OctStr.new(0o644,'-rw-r--r--') ;-) 20:43
scullucs You can go higher (well, in unix anyway, dunno about windows): e.g. 07777 (The first 7 is sticky bit(1) + set group ID on execution(2) + set user ID on execution(4). 20:46
librasteve .oO 20:47
scullucs Er, 0o7777. 20:48
ab5tract That’s not “higher”, just longer :) 21:01
librasteve fwiw I think that this «IntStr.new(420, "0644")␤» is a great example of the value of allomorphs - in this case to continue to carry the semantic meaning of the permissions setting 21:03
21:04 jgaz left
&afk 21:04
lucs ab5tract: For some values of "higher", sure :) 21:11