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:57
Chanakan joined
01:07
jgaz left
02:20
deadmarshal_ left
02:43
deadmarshal_ joined
|
|||
pelevesque | Anyone can help a raku beginner? I have this string 54 34 185.00 F♯3 G♭3 Fs3 Gf3 I am wondering what is the easiest way to put 54 in one variable, 34 in other, 185.00 in a third, then the last 4 elements in one list together. I was thinking of splitting the string on spaces, and then in the array I find 0, 1, and 2, but is there a way to easily put together all elements after the 3rd in a list? | 02:45 | |
kjp | pelevesque: No need to join things back together again; just don't split them apart! split takes an optional second argument to specify how many pieces to split the input into; try something like "$string.split(/\s+/, 4)" | 04:25 | |
pelevesque | I found a super good solution with simply using .words | 05:16 | |
Thanks for that notion about the argument in split, I did not know this! | |||
I just came back today to Raku after months of Javascript only. God, it feels good. What a fantastic language. The best. | 05:17 | ||
08:02
dakkar joined
09:01
kjp_ joined,
RakuIRCLogger left,
kjp left
09:50
deadmarshal_ left
10:06
deadmarshal_ joined
12:50
lizmat left
13:04
lizmat joined
16:30
soverysour_ joined,
soverysour_ left
16:51
dakkar left
18:09
swaggboi left
|
|||
ab5tract | m: m: my ($a, $b, $tempo, @notes) = "54 34 185.00 F♯3 G♭3 Fs3 Gf3".split(/\s+/); dd :$a, :$b, :$tempo, :@notes | 18:51 | |
camelia | :a("54") :b("34") :notes(["F♯3", "G♭3", "Fs3", "Gf3"]) :tempo("185.00") |
||
ab5tract | pelevesque: an oldie but goodie ^^^ :) | ||
only works with one list, though, and it has to be composed of elements from the end of the string. but it does fit your example pretty well | 18:53 | ||
18:58
swaggboi joined
|
|||
lizmat | with that split string, you could just say .words :-) | 19:02 | |
ab5tract | good point. I always forget about that one | 19:32 | |
23:05
hudo_ joined
23:08
hudo left
23:35
hudo_ left,
hudo_ joined
|