-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a simple example of inverting @a to a Hash by reversing its keys and values #4561
Comments
I suggest breaking this existing doc verbiage (from https://docs.raku.org/type/List#routine_invert) where I've inserted a ▲:
by inserting this code:
Or perhaps instead add:
to the |
On Sat, Mar 1, 2025 at 18:10 raiph ***@***.***> wrote:
I suggest breaking this existing doc verbiage (from
https://docs.raku.org/type/List#routine_invert) where I've inserted a ▲:
Assumes every element of the List is a L<C|/type/Pair>. Returns all
elements as a
L<C|/type/Seq> of L<C|/type/Pair>s where the keys and values have been
exchanged. ▲ If the value of a L<C|/type/Pair> is an L<C|/type/Iterable>,
then it will expand the values
of that L<C|/type/Iterable> into separate pairs.
by inserting this code:
my @A = <array of four strings>;
say @a.pairs.invert.hash; # {array => 0, four => 2, of => 1, strings => 3}
If you're OK with that I'll do a doc PR/commit for it.
—
Reply to this email directly, view it on GitHub
<#4561 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAH5VVGHSAAXYYKV2I7DIGD2SJD63AVCNFSM6AAAAABYEL6PCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSGQ4DANJWGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: raiph]*raiph* left a comment (Raku/doc#4561)
<#4561 (comment)>
I suggest breaking this existing doc verbiage (from
https://docs.raku.org/type/List#routine_invert) where I've inserted a ▲:
That would be very useful, thank you!
|
I think the .antipairs method alone is the best way to show the way. Maybe just improve its indexing in the docs. |
No description provided.
The text was updated successfully, but these errors were encountered: