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:17
MasterDuke joined
09:01
dakkar joined
09:03
Manifest0 joined
14:04
librasteve_ left
17:31
dakkar left
19:02
librasteve_ joined
|
|||
Tirifto | m: for 1..9 { my %h = :a, :b, :c, :d; for %h { .key.print; %h<d>:delete }; say “” } | 19:10 | |
camelia | cba bdac bca ccba dcba dbca aacb bac aacb |
||
Tirifto | I suppose hashes are not meant to be messed with while they’re being iterated over with ‘for’? | 19:13 | |
librasteve | nss | ||
Tirifto | ~~ not so simple ? :o | 19:14 | |
librasteve | no shit sherlock | ||
(sorry that was a bit harsh) | |||
Tirifto | Ah, elementary it is. xP | 19:15 | |
librasteve | XD | 19:16 | |
or, as lizmat would say, doctor it hurts when I do that | |||
nahita3882 | what's the reason &postcircumfix:<( )> is not accessible like this? | 19:18 | |
works for {} and [] | |||
Tirifto | (No harm done! c: I reckon this might be common sense, but I tend to imagine Raku as a hyperbolic land of endless possibilities, so I had to check. xP) | ||
nahita3882 | m: &postcircumfix:<( )> | 19:19 | |
Raku eval | Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Undeclared routine: postcircumfix:<( )> used at line 1. Did you mean 'postcircumfix:<{ }>', 'postcircumfix:<[ ]>', 'postcircumfix:<[; ]>', 'postcircumfix:<{; }>'? | ||
lizmat | nahita3882 possibly because postcircumfix ( ) is really a syntactic construct | ||
although I don't see a reason why it couldn't exist | 19:20 | ||
nahita3882 | i see thanks | 19:21 | |
lizmat | m: sub postcircumfix:<( )>($callable, |c) { $callable(|c) }; &postcircumfix:<( )>({ say "foo: $_" }, 42) | 19:23 | |
camelia | foo: 42 | 19:24 | |
librasteve | Tirifto: you made me wonder whether other languages lock out the iterand - and whether raku (like perl) is deliberately relaxed since there may be certain self-referential code (aka footguns) that you could do (but would want to) | ||
Tirifto | I don’t think I’ve tried, other than maybe Citrine, where I think it worked. `o` | 19:28 | |
Assuming I want to iterate over some values (ordered or not), but might decide while iterating that I shan’t be needing to look at some of those values any more, is there a straightforward way for me to exclude those values from iteration? Or might I be better off recording such values in a SetHash (for example) and skipping them over as they come? | 19:35 | ||
lizmat | there's "last" in loops ? | 19:47 | |
Tirifto | Yes, but that always skips over all the remaining values, rather than only excluding a select few, no? | 19:49 | |
lizmat | "next if $not-applicable" | 19:55 | |
Tirifto | Very well! | 20:49 |