![]() |
|
Navigation |
Synopsis Merge the elements of two sorted lists into one list.
Function
Usage
import List;
Description Merge the elements of two sorted lists into one list using the built-in ordering between values.
Optional, a comparison function
lessOrEqual may be given for a user-defined ordering between values.
Examples
rascal>import List; ok rascal>merge([1, 3, 5], [2, 7, 9, 15]); list[int]: [1,2,3,5,7,9,15] rascal>merge(["ape", "elephant", "owl", "snale", "zebra"], ["apple", "berry", "orange", "pineapple"]); list[str]: ["ape","apple","berry","elephant","orange","owl","pineapple","snale","zebra"]Merge two lists of strings and use their length as ordering: rascal>import String; ok rascal>merge(["ape", "owl", "snale", "zebra", "elephant"], ["apple", "berry", "orange", "pineapple"], bool(str x, str y){ return size(x) <= size(y); }); list[str]: ["ape","owl","snale","zebra","apple","berry","orange","elephant","pineapple"] Questions
Question [1].
![]() ![]()
Question [2].
![]() ![]()
Question [3].
![]() ![]() ![]() |