Synopsis Mix the elements of two lists.
Function list[&T] mix(list[&T] l, list[&T] r)
Usage import List;
Description Let n be the minimum of the length of the two lists l and r. mix returns a list in which the first n elements are taken alternately from the left and the right list, followed by the remaining elements of the longest list.
rascal>import List;
rascal>mix([3, 1, 7, 5, 9], [15, 25, 35]);
list[int]: [3,15,1,25,7,35,5,9]
rascal>mix([3, 1, 7], [15, 25, 35, 45, 55]);
list[int]: [3,15,1,25,7,35,45,55]
rascal>mix([3, 1, 7], ["elephant", "snake"]);
list[value]: [3,"elephant",1,"snake",7]

Question [1]. Given two lists of length N, respectively, M. What is the length of the mixed list:

Question [2].
The type of mix([-1, -6, -17], [13, 14, -4, 14, 4]) is

Question [3].
mix(["Melon", "Telly Monster", "Grover", "Eggplant"], ["Obi-Wan Kenobi", "Jabba the Hut", "Count Von Count", "Fig", "M"]) == 

Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit