![]() |
|
Navigation |
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.
Examples
rascal>import List; ok 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] Questions
Question [1].
![]() ![]() N , respectively, M . What is the length of the mixed list:
Question [2].
![]() ![]()
Question [3].
![]() ![]() ![]() |