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:03
habere-et-disper left
00:42
Heptite left
00:43
Heptite joined
01:02
Manifest0 left
01:04
guifa joined
01:15
deoac joined
|
|||
deoac | m: my $s = 'Hello, World!'; $s.subst: / ( e | o ) /, "\\$0", :g | 01:16 | |
camelia | Use of Nil in string context in block <unit> at <tmp> line 1 |
||
deoac | m: my $s = 'Hello, World!'; $s.subst: / ( e | o ) /, "\\$0", :g; say $s | ||
camelia | Use of Nil in string context Hello, World! in block <unit> at <tmp> line 1 |
||
deoac | m: my $s = 'Hello, World!'; $s.subst(/ ( e | o ) /, "\\$0", :g); say $s | ||
camelia | Use of Nil in string context Hello, World! in block <unit> at <tmp> line 1 |
||
deoac | Well anyway, in the REPL, the output is `H\ell\e, W\erld!` How do I get it TDWIM? | 01:17 | |
m: my $s = 'Hello, World!'; $s .= subst(/ ( e | o ) /, "\\$0", :g); say $s | 01:19 | ||
camelia | Use of Nil in string context H\ll\, W\rld! in block <unit> at <tmp> line 1 |
||
MasterDuke | m: my $s = "Hello, World!"; $s .= subst(/ ( e | o ) /, {$0 ?? "\\$0" !! ""}, :g); say $s | 01:28 | |
camelia | H\ell\o, W\orld! | ||
01:51
deoac left
|
|||
rf | m: my $s = "Hello, World!"; $s .= subst(/ ( e | o ) /, { "\\$0" }, :g); say $s | 02:02 | |
camelia | H\ell\o, W\orld! | ||
rf | m: my $s = "Hello, World!"; $s .= subst(/ ( e | o ) /, '\' ~ *, :g); say $s | 02:04 | |
camelia | ===SORRY!=== Error while compiling <tmp> Unable to parse expression in single quotes; couldn't find final "'" (corresponding starter was at line 1) at <tmp>:1 ------> ubst(/ ( e | o ) /, '\' ~ *, :g); say $s⏏<EOL> expecting … |
||
rf | m: my $s = "Hello, World!"; $s .= subst(/ ( e | o ) /, "\\" ~ *, :g); say $s | ||
camelia | H\ell\o, W\orld! | ||
02:29
deoac joined
|
|||
deoac | Wow, three good and interesting solutions. Thank you. | 02:34 | |
02:35
deoac left
04:22
rf left
04:24
rf joined
04:42
rf left,
rf joined
04:59
jcb28 joined
|
|||
AirwaveDev | somebody help me setup comma ide i messed setup and can't compile scripts in ide | 05:04 | |
ahoy please | 05:13 | ||
never mind figured it out | 05:23 | ||
feeling great today and yesterday been great i solved all problems and issues i have been facing with my pc , setups and programmes | 05:36 | ||
05:47
jcb28 left
06:35
Heptite left
06:47
teatwo joined
06:50
teatime left
07:53
Sussysham joined
08:06
Sussysham left
08:54
dakkar joined
12:50
habere-et-disper joined
|
|||
habere-et-disper | Hello Raccoons ! o/ | 12:53 | |
How do we unpair a pair ? | |||
It seems somewhat verbose to do: | |||
m: ( 1 => 'one' ).map( | *.kv ) | |||
camelia | ( no output ) | ||
Nemokosch | m: ( 1 => 'one' ).kv.say | 12:54 | |
Raku eval | (1 one) | ||
Nemokosch | you said one pair, right? 🙂 | ||
habere-et-disper | Haha... yes it doesn't work with more than one! | ||
Nemokosch | mind you - ( 1 => 'one' ) is one pair, not a list of pairs | 12:55 | |
parentheses play no part in list construction, they only disambiguate precendence | 12:56 | ||
habere-et-disper | Oh, and can we specify the endpoint of a generating function to be if the term has appeared already ? | ||
I have something like this is mind... | 12:59 | ||
( 1, { .some-sub } ... * ) | |||
where * is changed to test if the term has already appeared | |||
lizmat | use a variable for * ? | 13:00 | |
habere-et-disper | I imagined something like: | 13:01 | |
( 1, { .some-sub } ... * (elem) self ) | |||
Nemokosch | not sure if you can reference the sequence under construction itself | 13:06 | |
m: my @demo = 1, { (1..10).roll } ... { ++(%){$_} > 1 }; dd @demo; | 13:14 | ||
Raku eval | Array @demo = [1, 5, 7, 3, 5] | ||
Nemokosch | well, funky | 13:15 | |
another iteration of the same "saga": | 13:16 | ||
m: my @demo = 1, { (1..10).roll } ... { not (%){$_}++ }; dd @demo; | |||
Raku eval | Array @demo = [1] | ||
Nemokosch | uh oh | ||
shouldn't have negated, I guess | |||
m: my @demo = 1, { (1..10).roll } ... { (%){$_}++ }; dd @demo; | |||
Raku eval | Array @demo = [1, 2, 3, 1] | ||
Nemokosch | yup, better | ||
habere-et-disper | WOW ! That works ! Thanks @Nemokosch. What is the (%) doing? It's not casting to Hash now is it ? | 13:24 | |
Nemokosch | docs.raku.org/language/variables.h...%_variable | ||
it needed to be disambiguated with the parens | |||
so basically you have a static % variable all along that you can access on each iteration, setting keys on it | 13:25 | ||
the first time you hit a non-zero value, the game is over | |||
habere-et-disper | Perfect ! Wondeful. | 13:26 | |
:D | |||
Nemokosch | a very tempting solution once you know how it works 😄 | 13:27 | |
mandatory disclaimer that static variables aren't thread safe but this problem doesn't seem to be parallelization-friendly to begin with, the whole thing would be in a lock | 13:28 | ||
lizmat | s/static/state | 13:38 | |
Nemokosch | they are the same thing tbh | ||
14:17
Heptite joined
|
|||
habere-et-disper | I've forgotten the way to introspect the middle of a method chain. These don't work: | 15:33 | |
m: 123.&( * * 2 ).raku.&( * * 3 ).say | |||
camelia | 738 | ||
habere-et-disper | m: 123.&( * * 2 ).note.&( * * 3 ).say | ||
camelia | 246 3 |
||
Nemokosch | in recent versions (like the one that the IRC evalbot uses), there is snitch | ||
lizmat | docs.raku.org/routine/snitch.html | ||
Nemokosch | ^^ | 15:34 | |
habere-et-disper | Merci ! | ||
16:01
habere-et-disper left
16:25
saint- joined
16:42
deoac joined
17:14
deoac left
17:19
habere-et-disper joined
17:39
dakkar left
17:56
habere-et-disper left
17:57
discord-raku-bot left
17:58
discord-raku-bot joined
|
|||
nHail | So this code works: my @b; for ^9 X ^9 -> (\x, \y) { @b[x][y] = '...' #some stuff in here involving @a } @a = @b But this code gives me an error Cannot modify an immutable Str (-): for ^9 X ^9 -> (\x, \y) { @a[x][y] = '...' # the same stuff as before } The '-' is an element of the array, but it should just be changing the element at that index, not trying to change the str itself | 18:12 | |
rf | Can you show the #some stuff involving @a? | 18:24 | |
nHail | (conditions on @a[x][y] and its neighbors, not modifying them) ?? h !! @a[x][y] | 18:30 | |
It's part of a code golf problem, otherwise I would post the whole like | 18:34 | ||
rf | Can you pastebin it, I don't see from what you've provided where you could possibly hit that error | 18:42 | |
18:48
tea3po joined
18:49
tea3po left
18:50
tea3po joined
18:51
teatwo left
|
|||
Nemokosch | @nHail is it possible that the elements of @a are bare Lists? | 18:58 | |
as opposed to Arrays | |||
nHail | It should be a Seq | 19:00 | |
from comb | |||
Nemokosch | well then bingo | 19:01 | |
that yields non-writeable stuff | |||
nHail | Oh | ||
Nemokosch | I wonder if you could force it to return Scalars, not out of question | 19:02 | |
but perhaps that's not the best way to resolve it | |||
21:23
ab5tract left
22:52
habere-et-disper joined
23:11
saint- left
|