00:15 lizmat_ joined 00:18 lizmat left 03:33 bruceAxtens joined
bruceAxtens Regarding 'ACTU'.split("").Array.map(-> $v { $v.ord }) 03:34
(Nil 65 67 84 85 Nil)
why do i get Nil either side? 03:35
And how can I not get Nil. I just want the ascii values
03:42 bruceAxtens left 05:15 RavingCodRoller joined 05:33 RavingCodRoller left
lakmatiol Consider using .comb instead of .split(''). 06:21
m: say 'TUV'.comb.map(*.ord) 06:22
09:22 parv joined 09:33 lizmat_ left, lizmat joined 11:35 parv left 12:12 discord-raku-bot left 12:13 discord-raku-bot joined
SmokeMachine m: say 'TUV'.comb.map(*.ord) # running for lakmatiol#8020 13:01
camelia (84 85 86)
axtens thank you 13:48
SmokeMachine :) 14:41
15:25 sm2 joined 15:53 parv joined 16:10 parv left 16:24 CIAvash left 16:36 CIAvash joined 16:37 sm2 left 16:39 SmokeMachine left, tbrowder left 16:40 mjgardner left 16:42 mjgardner joined, SmokeMachine joined 16:45 tbrowder joined 16:50 suman joined
suman say $_ if $_~~ /regex/ for "file".IO.lines gives the line that match the regex. 16:50
How to get the line immediately after the match?
gfldex m: say lines.WHAT; 17:31
m: .say for lines; 17:32
m:``` 17:34
for my \l = lines {
last if / 'may' /;
}
say l.head;
```
m:```
for my \l = lines() {
last if / 'may' /;
}
say l.head;
```
17:39 suman left
m:``` 17:41
my @l = lines;
while @l.shift {
last when / 'may' /;
}
say @l.head;
```
my @l = lines; 17:45
while @l.shift -> $_ {
last when / 'may' /;
}
say @l.head;
17:46 lizmat_ joined
Using `.first(/ 'may' /, :kv)` would work too ofc. 17:46
17:47 lizmat_ left, lizmat_ joined 17:49 lizmat left, lizmat_ left, lizmat joined
Nemokosch how can I pass an optional argument to a sub? 18:30
when it's not a constant value
lizmat sub foo($a = 42) { ... } # $a is optional with 42 as default 18:31
sub foo($a?) { ... } # $a is optional with Any as default 18:32
Nemokosch wait, it's not even optional...
lizmat what isn't optional?
Nemokosch so there is the `extension` sub
it has :$parts = 1
lizmat m: sub foo($a = 42) { $a }; say foo 18:33
camelia 42
Nemokosch I want to set this to the value I figure out
lizmat :$parts is a named parameter
Nemokosch yes, my bad
lizmat sub foo(:$parts = 42) { $parts }; say foo
Nemokosch the question holds with named parameter šŸ™‚
lizmat m: sub foo(:$parts = 42) { $parts }; say foo
camelia 42
lizmat m: sub foo(:$parts = 42) { $parts }; say foo parts => 137
camelia 137
Nemokosch oh okay, so like a hash? 18:34
lizmat no 18:37
a => 42 is a first class citizen in Raku
it's called a Pair
by default, Pairs specified in a call, are interpreted as named arguments
Morfent if you wrap a pair in parentheses it'll get treated like a positional argument 19:04
ditto making a slip out of a list of pairs
for variadic named arguments, you need to slip a hash of sorts 19:05
lizmat |%hash ?
Morfent yep
lizmat m: my %h = a => 42, b => 666; sub a(:$a, :$b) { dd $a, $b }; a |%h 19:06
camelia 42
666
19:06 ajr joined
Nemokosch I mean, hashes consist of "pairs" if we insist on this terminology 19:19
lizmat yes, you could consider a has an unordered list of pairs 19:28
in fact, if you iterate over a hash, that's exactly what you get
19:29 parv joined
lizmat m: my %h = a => 42, b => 666, c => 137; dd $_ for %h 19:29
camelia :b(666)
:a(42)
:c(137)
lizmat m: my %h = a => 42, b => 666, c => 137; dd $_ for %h
camelia :a(42)
:c(137)
:b(666)
lizmat note the order is indeterminate
Nemokosch gotcha 20:35
21:02 ajr left 21:13 ajr joined 21:18 ajr left 21:43 ajr joined