mesh#

Interleave multiple arrays, padding shorter ones with undef.

Registered under both mesh and mesh_longest. Both forms stop at the length of the longest input and fill missing elements with undef.

תקציר#

my @out = mesh         \@a, \@b, \@c;
my @out = mesh_longest \@a, \@b, \@c;
my %h   = mesh \@keys, \@values;

מה מוחזר#

A flat list containing elements at position 0 from each input array, then position 1, and so on, up to the longest input. Missing positions are filled with undef.

דוגמאות#

my @r = mesh [1..3], ['a'..'c'];          # (1,'a', 2,'b', 3,'c')
my @r = mesh [1..3], ['a'..'b'];          # (1,'a', 2,'b', 3,undef)
my %h = mesh \@keys, \@values;            # build a hash

מקרי קצה#

  • An input that is not an arrayref contributes only undefs.

  • Empty input list returns an empty list.

הבדלים מן ה-upstream#

Fully compatible with upstream.

ראו גם#

  • mesh_shortest - stop at the shortest input.

  • zip - same lockstep walk, but yields one arrayref per row.