sub roundrobin

Documentation for sub roundrobin assembled from the following types:

class List

From List

(List) routine roundrobin

Defined as:

sub roundrobin(+list-of-lists --> Seq)

Builds a 'list of lists', returned as a sequence, from multiple input lists or other iterables. roundrobin returns an identical result to that of zip, except when the input lists are allowed to have an unequal number of elements.

say roundrobin <a b c>, <d e f>, <g h i>;
# OUTPUT: «((a d g) (b e h) (c f i))␤» 
 
say .join(","for roundrobin([12], [23], [34]);
# OUTPUT: «1,2,3␤ 
# 2,3,4␤» 

roundrobin does not terminate once one or more of the input lists become exhausted, but proceeds until all elements from all lists have been processed.

say roundrobin <a b c>, <d e f m n o p>, <g h i j>;
# OUTPUT: «((a d g) (b e h) (c f i) (m j) (n) (o) (p))␤» 
 
say .join(","for roundrobin([12], [235777], [34102]);
# OUTPUT: «1,2,3␤ 
# 2,3,4␤ 
# 57,102␤ 
# 77␤» 

Therefore no data values are lost due in the 'zipping' operation. A record of which input list provided which element cannot be gleaned from the resulting sequence, however.

roundrobin can be useful in combining messy data to the point where a manual post-processing step can then be undertaken.