zip_shortest#

Walk multiple arrays in lockstep, stopping at the shortest.

תקציר#

my @rows = zip_shortest \@a, \@b, \@c;

מה מוחזר#

A list of arrayrefs, one per row. Row i contains the i-th element of each input array - produced only while every input still has an i-th element. No undef padding.

דוגמאות#

my @r = zip_shortest [1..3], ['a','b'];   # ([1,'a'], [2,'b'])
my @r = zip_shortest [1..3], [];          # ()

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

Fully compatible with upstream.

ראו גם#

  • zip / zip_longest - pad to longest instead.

  • mesh_shortest - flatten the rows instead of wrapping in arrayrefs.