WeixiangYan/CodeTransOcean huggingface dataset:
Task: Nested function

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
	char str[30];
}item;

item* makeList(char* separator){
	int counter = 0,i;
	item* list = (item*)malloc(3*sizeof(item));
	
	item makeItem(){
		item holder;
		
		char names[5][10] = {"first","second","third","fourth","fifth"};
		
		sprintf(holder.str,"%d%s%s",++counter,separator,names[counter]);
		
		return holder;
	}
	
	for(i=0;i<3;i++)
		list[i] = makeItem();
	
	return list;
}

int main()
{
	int i;
	item* list = makeList(". ");
	
	for(i=0;i<3;i++)
		printf("\n%s",list[i].str);
	
	return 0;
}











Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function


C++: #include <iostream>
#include <string>
#include <vector>
 
std::vector<std::string> makeList(std::string separator) {
  auto counter = 0;
  auto makeItem = [&](std::string item) {
    return std::to_string(++counter) + separator + item;
  };
  return {makeItem("first"), makeItem("second"), makeItem("third")};
}

int main() {
  for (auto item : makeList(". "))
    std::cout << item << "\n";
}










Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function




Go: package main
import "fmt"

func makeList(separator string) string {
    counter := 1

    makeItem := func(item string) string {
        result := fmt.Sprintf("%d%s%s\n", counter, separator, item)
        counter += 1
        return result
    }

    return makeItem("first") + makeItem("second") + makeItem("third")
}

func main() {
    fmt.Print(makeList(". "))
}








Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function





Java: module NestedFunction
    {
    static String makeList(String separator)
        {
        Int counter = 1;

        function String(String) makeItem = item -> $"{counter++}{separator}{item}\n";

        return makeItem("first")
             + makeItem("second")
             + makeItem("third");
        }

    void run()
        {
        @Inject Console console;
        console.print(makeList(". "));
        }
    }







Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function







Python: def makeList(separator):
    counter = 1

    def makeItem(item):
        nonlocal counter
        result = str(counter) + separator + item + "\n"
        counter += 1
        return result

    return makeItem("first") + makeItem("second") + makeItem("third")

print(makeList(". "))





Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function








VB: Option Explicit

Private Const Sep As String = ". "
Private Counter As Integer
Sub Main()
Dim L As Variant
    Counter = 0
    L = MakeList(Array("first", "second", "third"))
    Debug.Print L
End Sub
Function MakeList(Datas) As Variant
Dim i As Integer
    For i = LBound(Datas) To UBound(Datas)
        MakeList = MakeList & MakeItem(Datas(i))
    Next i
End Function
Function MakeItem(Item As Variant) As Variant
    Counter = Counter + 1
    MakeItem = Counter & Sep & Item & vbCrLf
End Function




Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Nested function

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
	char str[30];
}item;

item* makeList(char* separator){
	int counter = 0,i;
	item* list = (item*)malloc(3*sizeof(item));
	
	item makeItem(){
		item holder;
		
		char names[5][10] = {"first","second","third","fourth","fifth"};
		
		sprintf(holder.str,"%d%s%s",++counter,separator,names[counter]);
		
		return holder;
	}
	
	for(i=0;i<3;i++)
		list[i] = makeItem();
	
	return list;
}

int main()
{
	int i;
	item* list = makeList(". ");
	
	for(i=0;i<3;i++)
		printf("\n%s",list[i].str);
	
	return 0;
}
Task: Nested function



C#: string MakeList(string separator)
{
    int counter = 1;

    Func<string, string> makeItem = item => counter++ + separator + item + "\n";

    return makeItem("first") + makeItem("second") + makeItem("third");
}

Console.WriteLine(MakeList(". "));
Task: Nested function


C++: #include <iostream>
#include <string>
#include <vector>
 
std::vector<std::string> makeList(std::string separator) {
  auto counter = 0;
  auto makeItem = [&](std::string item) {
    return std::to_string(++counter) + separator + item;
  };
  return {makeItem("first"), makeItem("second"), makeItem("third")};
}

int main() {
  for (auto item : makeList(". "))
    std::cout << item << "\n";
}
Task: Nested function





Java: module NestedFunction
    {
    static String makeList(String separator)
        {
        Int counter = 1;

        function String(String) makeItem = item -> $"{counter++}{separator}{item}\n";

        return makeItem("first")
             + makeItem("second")
             + makeItem("third");
        }

    void run()
        {
        @Inject Console console;
        console.print(makeList(". "));
        }
    }
Task: Nested function







Python: def makeList(separator):
    counter = 1

    def makeItem(item):
        nonlocal counter
        result = str(counter) + separator + item + "\n"
        counter += 1
        return result

    return makeItem("first") + makeItem("second") + makeItem("third")

print(makeList(". "))
Task: Nested function








VB: Option Explicit

Private Const Sep As String = ". "
Private Counter As Integer
Sub Main()
Dim L As Variant
    Counter = 0
    L = MakeList(Array("first", "second", "third"))
    Debug.Print L
End Sub
Function MakeList(Datas) As Variant
Dim i As Integer
    For i = LBound(Datas) To UBound(Datas)
        MakeList = MakeList & MakeItem(Datas(i))
    Next i
End Function
Function MakeItem(Item As Variant) As Variant
    Counter = Counter + 1
    MakeItem = Counter & Sep & Item & vbCrLf
End Function
Task: Nested function




Go: package main
import "fmt"

func makeList(separator string) string {
    counter := 1

    makeItem := func(item string) string {
        result := fmt.Sprintf("%d%s%s\n", counter, separator, item)
        counter += 1
        return result
    }

    return makeItem("first") + makeItem("second") + makeItem("third")
}

func main() {
    fmt.Print(makeList(". "))
}
Task: Nested function



C#: string MakeList(string separator)
{
    int counter = 1;

    Func<string, string> makeItem = item => counter++ + separator + item + "\n";

    return makeItem("first") + makeItem("second") + makeItem("third");
}

Console.WriteLine(MakeList(". "));








Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function


C++: #include <iostream>
#include <string>
#include <vector>
 
std::vector<std::string> makeList(std::string separator) {
  auto counter = 0;
  auto makeItem = [&](std::string item) {
    return std::to_string(++counter) + separator + item;
  };
  return {makeItem("first"), makeItem("second"), makeItem("third")};
}

int main() {
  for (auto item : makeList(". "))
    std::cout << item << "\n";
}









Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function

C: #include<stdlib.h>
#include<stdio.h>

typedef struct{
	char str[30];
}item;

item* makeList(char* separator){
	int counter = 0,i;
	item* list = (item*)malloc(3*sizeof(item));
	
	item makeItem(){
		item holder;
		
		char names[5][10] = {"first","second","third","fourth","fifth"};
		
		sprintf(holder.str,"%d%s%s",++counter,separator,names[counter]);
		
		return holder;
	}
	
	for(i=0;i<3;i++)
		list[i] = makeItem();
	
	return list;
}

int main()
{
	int i;
	item* list = makeList(". ");
	
	for(i=0;i<3;i++)
		printf("\n%s",list[i].str);
	
	return 0;
}










Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function




Go: package main
import "fmt"

func makeList(separator string) string {
    counter := 1

    makeItem := func(item string) string {
        result := fmt.Sprintf("%d%s%s\n", counter, separator, item)
        counter += 1
        return result
    }

    return makeItem("first") + makeItem("second") + makeItem("third")
}

func main() {
    fmt.Print(makeList(". "))
}







Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function





Java: module NestedFunction
    {
    static String makeList(String separator)
        {
        Int counter = 1;

        function String(String) makeItem = item -> $"{counter++}{separator}{item}\n";

        return makeItem("first")
             + makeItem("second")
             + makeItem("third");
        }

    void run()
        {
        @Inject Console console;
        console.print(makeList(". "));
        }
    }






Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function







Python: def makeList(separator):
    counter = 1

    def makeItem(item):
        nonlocal counter
        result = str(counter) + separator + item + "\n"
        counter += 1
        return result

    return makeItem("first") + makeItem("second") + makeItem("third")

print(makeList(". "))




Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function








VB: Option Explicit

Private Const Sep As String = ". "
Private Counter As Integer
Sub Main()
Dim L As Variant
    Counter = 0
    L = MakeList(Array("first", "second", "third"))
    Debug.Print L
End Sub
Function MakeList(Datas) As Variant
Dim i As Integer
    For i = LBound(Datas) To UBound(Datas)
        MakeList = MakeList & MakeItem(Datas(i))
    Next i
End Function
Function MakeItem(Item As Variant) As Variant
    Counter = Counter + 1
    MakeItem = Counter & Sep & Item & vbCrLf
End Function



Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function






PHP: <?
function makeList($separator) {
  $counter = 1;

  $makeItem = function ($item) use ($separator, &$counter) {
    return $counter++ . $separator . $item . "\n";
  };

  return $makeItem("first") . $makeItem("second") . $makeItem("third");
}

echo makeList(". ");
?>





Fortran:       FUNCTION F(X)
       REAL X
       DIST(U,V,W) = X*SQRT(U**2 + V**2 + W**2)    
        T = EXP(X)
        F = T + DIST(T,SIN(X),ATAN(X) + 7)         
      END
Task: Nested function






PHP: <?
function makeList($separator) {
  $counter = 1;

  $makeItem = function ($item) use ($separator, &$counter) {
    return $counter++ . $separator . $item . "\n";
  };

  return $makeItem("first") . $makeItem("second") . $makeItem("third");
}

echo makeList(". ");
?>
Task: Nested function






PHP: <?
function makeList($separator) {
  $counter = 1;

  $makeItem = function ($item) use ($separator, &$counter) {
    return $counter++ . $separator . $item . "\n";
  };

  return $makeItem("first") . $makeItem("second") . $makeItem("third");
}

echo makeList(". ");
?>






Ada: with Ada.Text_IO;

procedure Nested_Functions is 
   
   type List is array(Natural range <>) of String(1 .. 10);
   
   function Make_List(Separator: String) return List is
      Counter: Natural := 0;
      
      function Make_Item(Item_Name: String) return String is
      begin
	 Counter := Counter + 1; 
	 return(Natural'Image(Counter) & Separator & Item_Name);
      end Make_Item;
      
   begin
      return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
   end Make_List;
   
begin 
   for Item of Make_List(". ") loop
      Ada.Text_IO.Put_Line(Item);
   end loop;
end Nested_Functions;
Task: Sorting algorithms_Merge sort

C: #include <stdio.h>
#include <stdlib.h>

void merge (int *a, int n, int m) {
    int i, j, k;
    int *x = malloc(n * sizeof (int));
    for (i = 0, j = m, k = 0; k < n; k++) {
        x[k] = j == n      ? a[i++]
             : i == m      ? a[j++]
             : a[j] < a[i] ? a[j++]
             :               a[i++];
    }
    for (i = 0; i < n; i++) {
        a[i] = x[i];
    }
    free(x);
}

void merge_sort (int *a, int n) {
    if (n < 2)
        return;
    int m = n / 2;
    merge_sort(a, m);
    merge_sort(a + m, n - m);
    merge(a, n, m);
}

int main () {
    int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
    int n = sizeof a / sizeof a[0];
    int i;
    for (i = 0; i < n; i++)
        printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
    merge_sort(a, n);
    for (i = 0; i < n; i++)
        printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
    return 0;
}











Ada: generic
   type Element_Type is private;
   type Index_Type is (<>);
   type Collection_Type is array(Index_Type range <>) of Element_Type;
   with function "<"(Left, Right : Element_Type) return Boolean is <>;

package Mergesort is
   function Sort(Item : Collection_Type) return Collection_Type;
end MergeSort;
Task: Sorting algorithms_Merge sort


C++: #include <iterator>
#include <algorithm> 
#include <functional> 

template<typename RandomAccessIterator, typename Order>
 void mergesort(RandomAccessIterator first, RandomAccessIterator last, Order order)
{
  if (last - first > 1)
  {
    RandomAccessIterator middle = first + (last - first) / 2;
    mergesort(first, middle, order);
    mergesort(middle, last, order);
    std::inplace_merge(first, middle, last, order);
  }
}

template<typename RandomAccessIterator>
 void mergesort(RandomAccessIterator first, RandomAccessIterator last)
{
  mergesort(first, last, std::less<typename std::iterator_traits<RandomAccessIterator>::value_type>());
}










Ada: generic
   type Element_Type is private;
   type Index_Type is (<>);
   type Collection_Type is array(Index_Type range <>) of Element_Type;
   with function "<"(Left, Right : Element_Type) return Boolean is <>;

package Mergesort is
   function Sort(Item : Collection_Type) return Collection_Type;
end MergeSort;
Task: Sorting algorithms_Merge sort




Go: package main

import "fmt"

var a = []int{170, 45, 75, -90, -802, 24, 2, 66}
var s = make([]int, len(a)/2+1) 

func main() {
    fmt.Println("before:", a)
    mergeSort(a)
    fmt.Println("after: ", a)
}

func mergeSort(a []int) {
    if len(a) < 2 {
        return
    }
    mid := len(a) / 2
    mergeSort(a[:mid])
    mergeSort(a[mid:])
    if a[mid-1] <= a[mid] {
        return
    }
    
    copy(s, a[:mid])
    l, r := 0, mid
    for i := 0; ; i++ {
        if s[l] <= a[r] {
            a[i] = s[l]
            l++
            if l == mid {
                break
            }
        } else {
            a[i] = a[r]
            r++
            if r == len(a) {
                copy(a[i+1:], s[l:mid])
                break
            }
        }
    }
    return
}








Ada: generic
   type Element_Type is private;
   type Index_Type is (<>);
   type Collection_Type is array(Index_Type range <>) of Element_Type;
   with function "<"(Left, Right : Element_Type) return Boolean is <>;

package Mergesort is
   function Sort(Item : Collection_Type) return Collection_Type;
end MergeSort;
Task: Sorting algorithms_Merge sort





Java: import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

public class Merge{
    public static <E extends Comparable<? super E>> List<E> mergeSort(List<E> m){
        if(m.size() <= 1) return m;

        int middle = m.size() / 2;
        List<E> left = m.subList(0, middle);
        List<E> right = m.subList(middle, m.size());

        right = mergeSort(right);
        left = mergeSort(left);
        List<E> result = merge(left, right);

        return result;
    }

    public static <E extends Comparable<? super E>> List<E> merge(List<E> left, List<E> right){
        List<E> result = new ArrayList<E>();
        Iterator<E> it1 = left.iterator();
        Iterator<E> it2 = right.iterator();

	E x = it1.next();
	E y = it2.next();
        while (true){
            
            if(x.compareTo(y) <= 0){
		result.add(x);
		if(it1.hasNext()){
		    x = it1.next();
		}else{
		    result.add(y);
		    while(it2.hasNext()){
			result.add(it2.next());
		    }
		    break;
		}
	    }else{
		result.add(y);
		if(it2.hasNext()){
		    y = it2.next();
		}else{
		    result.add(x);
		    while (it1.hasNext()){
			result.add(it1.next());
		    }
		    break;
		}
	    }
        }
        return result;
    }
}







Ada: generic
   type Element_Type is private;
   type Index_Type is (<>);
   type Collection_Type is array(Index_Type range <>) of Element_Type;
   with function "<"(Left, Right : Element_Type) return Boolean is <>;

package Mergesort is
   function Sort(Item : Collection_Type) return Collection_Type;
end MergeSort;
Task: Sorting algorithms_Merge sort







Python: fun mergesort(m):
    if m.lenght <= 1: return m
    let middle = floor m.lenght / 2
    let left = merge(m[:middle])
    let right = merge(m[middle-1:]);

fun merge(left, right):
    let result = []
    while not (left.isempty or right.isempty):
        if left[1] <= right[1]:
            result.push! left.shift!()
        else:
            result.push! right.shift!()
    result.push! left.push! right

let arr = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]
print mergesort arr





Ada: generic
   type Element_Type is private;
   type Index_Type is (<>);
   type Collection_Type is array(Index_Type range <>) of Element_Type;
   with function "<"(Left, Right : Element_Type) return Boolean is <>;

package Mergesort is
   function Sort(Item : Collection_Type) return Collection_Type;
end MergeSort;
Task: Sorting algorithms_Merge sort

C: #include <stdio.h>
#include <stdlib.h>

void merge (int *a, int n, int m) {
    int i, j, k;
    int *x = malloc(n * sizeof (int));
    for (i = 0, j = m, k = 0; k < n; k++) {
        x[k] = j == n      ? a[i++]
             : i == m      ? a[j++]
             : a[j] < a[i] ? a[j++]
             :               a[i++];
    }
    for (i = 0; i < n; i++) {
        a[i] = x[i];
    }
    free(x);
}

void merge_sort (int *a, int n) {
    if (n < 2)
        return;
    int m = n / 2;
    merge_sort(a, m);
    merge_sort(a + m, n - m);
    merge(a, n, m);
}

int main () {
    int a[] = {4, 65, 2, -31, 0, 99, 2, 83, 782, 1};
    int n = sizeof a / sizeof a[0];
    int i;
    for (i = 0; i < n; i++)
        printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
    merge_sort(a, n);
    for (i = 0; i < n; i++)
        printf("%d%s", a[i], i == n - 1 ? "\n" : " ");
    return 0;
}
Task: Sorting algorithms_Merge sort


C++: #include <iterator>
#include <algorithm> 
#include <functional> 

template<typename RandomAccessIterator, typename Order>
 void mergesort(RandomAccessIterator first, RandomAccessIterator last, Order order)
{
  if (last - first > 1)
  {
    RandomAccessIterator middle = first + (last - first) / 2;
    mergesort(first, middle, order);
    mergesort(middle, last, order);
    std::inplace_merge(first, middle, last, order);
  }
}

template<typename RandomAccessIterator>
 void mergesort(RandomAccessIterator first, RandomAccessIterator last)
{
  mergesort(first, last, std::less<typename std::iterator_traits<RandomAccessIterator>::value_type>());
}
Task: Sorting algorithms_Merge sort





Java: import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;

public class Merge{
    public static <E extends Comparable<? super E>> List<E> mergeSort(List<E> m){
        if(m.size() <= 1) return m;

        int middle = m.size() / 2;
        List<E> left = m.subList(0, middle);
        List<E> right = m.subList(middle, m.size());

        right = mergeSort(right);
        left = mergeSort(left);
        List<E> result = merge(left, right);

        return result;
    }

    public static <E extends Comparable<? super E>> List<E> merge(List<E> left, List<E> right){
        List<E> result = new ArrayList<E>();
        Iterator<E> it1 = left.iterator();
        Iterator<E> it2 = right.iterator();

	E x = it1.next();
	E y = it2.next();
        while (true){
            
            if(x.compareTo(y) <= 0){
		result.add(x);
		if(it1.hasNext()){
		    x = it1.next();
		}else{
		    result.add(y);
		    while(it2.hasNext()){
			result.add(it2.next());
		    }
		    break;
		}
	    }else{
		result.add(y);
		if(it2.hasNext()){
		    y = it2.next();
		}else{
		    result.add(x);
		    while (it1.hasNext()){
			result.add(it1.next());
		    }
		    break;
		}
	    }
        }
        return result;
    }
}