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.
01:54 Kaiepi left 02:13 deoac left 02:24 frost91 joined 02:57 frost91 left 04:27 Heptite left 04:40 [Coke]_ joined 04:42 [Coke]__ left 05:39 razetime joined 06:27 frost53 joined 06:42 kjp left 06:43 kjp joined 06:59 razetime left 07:59 habere-et-disper joined 08:02 Kaiepi joined
habere-et-disper To reference a hash index, one can do `%hash{ $index }` 08:03
Can it be done somehow the other way round with the `$index` part first?
Nemokosch I suppose it doesn't count if you define an operator for yourself? 08:11
habere-et-disper I was just thinking about the flexibility of composition and wondering if I had missed something obvious... 08:14
Kaiepi if just the single key variant of `&postcircumfix:{ }` is fine, you can define an operator that delegates to `AT-KEY` on the hash 08:18
if just the single key variant of `&postcircumfix:<{ }>` is fine, you can define an operator that delegates to `AT-KEY` on the hash
multiple looks a bit awkward, but adverbs are the main thing that makes this tricky normally 08:21
Nemokosch `$index ==> &postcircumfix:<{ }>(%hash)` does work, by the way 08:22
not sure how fun that is, lol
Kaiepi that shouldn't be terribly different from a normal postcircumfix call, surprisingly 08:26
Nemokosch by the way, is there a shorter way to refer to this operator? 08:29
like &[>] for the infix >
habere-et-disper Thanks! 08:30
I got lost at:
m: my %letters = pairs 'a'..'z'; say 12.map: %letters{ $_ }
camelia Use of uninitialized value $_ of type Any in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
in block <unit> at <tmp> line 1
Use of uninitialized value $_ of type Any in string context…
Kaiepi `*{ }` is valid i guess 08:31
`$_` wants a block around it there habere-et-disper
Nemokosch what Kaiepi said: it's not a callable but a bare value this way 08:33
a bare %letters{ Any } value
habere-et-disper Still unhappy?
m: my %letters = pairs 'a'..'z'; say 12.map: %letters{ { $_ } }
camelia Block object coerced to string (please use .gist or .raku to do that)
in block <unit> at <tmp> line 1
Block object coerced to string (please use .gist or .raku to do that)
in block <unit> at <tmp> line 1
Cannot map a Int using 'Any'
Did …
habere-et-disper Okay, I got it! 08:34
m: my %letters = pairs 'a'..'z'; say 12.map: { %letters{ $_ } }
camelia (m)
Nemokosch no, not that way... 08:35
bingo
habere-et-disper Yay! Thanks Kaiepi & discord-raku-bot :-)
Nemokosch <@210313526928080896> I don't think `*{ }` does what it should 08:37
or better said, I'm not sure if it means what we wished it would 08:38
Kaiepi yeah... 08:39
Nemokosch I wonder, though, what `*{*}` is 08:41
I thought it would be like `{ $^a{$^b} }`
apparently it isn't
08:43 CIAvash left, andrea[m] left
Kaiepi one of the `*` makes a `WhateverCode:D`, but i think the one on the rhs would just be a literal `Whatever:D`, not any argument that can be given 08:43
Nemokosch seems like you are right
it's a tricky way to write .values, lol
08:51 CIAvash joined 09:45 andrea[m] joined
guifa Rule of thumb: whatevers as *arguments* are always whatevers, and don't interpolate 10:08
Nemokosch okay but the second * in `*{*}` is not really more of an argument than the second * would be in `* + *` 10:10
11:00 equinox joined 11:08 equinox left 11:27 habere-et-disper left 12:09 equinox joined 12:32 frost53 left 12:42 equinox left 12:45 Kaiepi left 12:50 archenoth joined 12:53 Kaiepi joined 13:32 jgaz joined 14:02 Newbie21 joined 14:37 Heptite joined
Rog Hm, yeah, the Whatever-currying docs don’t mention hash indexing as a special case 15:31
So one would imagine it to be what Nemokosch suggested above
I don’t know whether that’s a bug or intentional behavior but at this point we’re well beyond the scope of the “beginner” channel :P
17:20 equinox joined 18:14 jgaz left 19:24 equinox left 20:12 equinox joined 20:46 equinox left 21:23 Newbie21 left