Quick actions

cmd+k|ctrl+k

Navigation

Languages

Transposing-List-Of-Tuples

Snippet info

Language

Raku

Visibility

public

Author

221a86612c7785cb6094f25b034cba9994736288

Created

2025-08-14T15:13:15.997626Z

Updated

2025-08-14T15:29:40.19233Z

use Test;

#| reverse the zip operation
sub reverse-zip(@list-of-tuples) {
     [Z] @list-of-tuples
}

my @l1 = 1, 2, 3;
my @l2 = <a b c>;
my @input = zip @l1, @l2;
my @expected-output = @l1, @l2;

# we need to convert all elements of @expected-output to lists
# otherwise we get an error
is-deeply reverse-zip(@input), @expected-output;
is-deeply reverse-zip(@input), @expected-output».List;
INFO