WeixiangYan/CodeTransOcean huggingface dataset:
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}



C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}


C++: #include <iostream>
#include <vector>

int main() {
  std::vector<int> a;
  a.push_back(1);
  a.push_back(2);
  a.push_back(1);
  a.push_back(3);
  a.push_back(2);
  std::vector<int> b;
  b.push_back(1);
  b.push_back(2);
  b.push_back(0);
  b.push_back(4);
  b.push_back(4);
  b.push_back(0);
  b.push_back(0);
  b.push_back(0);

  std::cout << std::boolalpha << (a < b) << std::endl; 
  return 0;
}
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}




Go: package main

import "fmt"



func lessRune(a, b []rune) bool {
    return string(a) < string(b) 
}



type numericType int

func lessNT(a, b []numericType) bool {
    l := len(a)
    if len(b) < l {
        l = len(b)
    }
    for i := 0; i < l; i++ {
        if a[i] != b[i] {
            return a[i] < b[i]
        }
    }
    return l < len(b)
}

var testCases = [][][]numericType{
    {{0}, {}},
    {{}, {}},
    {{}, {0}},

    {{-1}, {0}},
    {{0}, {0}},
    {{0}, {-1}},

    {{0}, {0, -1}},
    {{0}, {0, 0}},
    {{0}, {0, 1}},
    {{0, -1}, {0}},
    {{0, 0}, {0}},
    {{0, 0}, {1}},
}

func main() {
    
    for _, tc := range testCases {
        fmt.Printf("order %6s before %6s : %t\n",
            fmt.Sprintf("%v", tc[0]),
            fmt.Sprintf("%v", tc[1]),
            lessNT(tc[0], tc[1]))
    }
    fmt.Println()

    
    
    for _, tc := range testCases {
        a := toByte(tc[0])
        b := toByte(tc[1])
        fmt.Printf("order %6q before %6q : %t\n",
            string(a),
            string(b),
            lessByte(a, b))
    }
}

func toByte(a []numericType) []byte {
    b := make([]byte, len(a))
    for i, n := range a {
        b[i] = 'b' + byte(n)
    }
    return b
}
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}





Java: import java.util.Arrays;
import java.util.List;

public class ListOrder{
	public static boolean ordered(double[] first, double[] second){
		if(first.length == 0) return true;
		if(second.length == 0) return false;
		if(first[0] == second[0])
			return ordered(Arrays.copyOfRange(first, 1, first.length),
					Arrays.copyOfRange(second, 1, second.length));
		return first[0] < second[0];
	}
	
	public static <T extends Comparable<? super T>> boolean ordered(List<T> first, List<T> second){
		int i = 0;
		for(; i < first.size() && i < second.size();i++){
			int cmp = first.get(i).compareTo(second.get(i));
			if(cmp == 0) continue;
			if(cmp < 0) return true;
			return false;
		}
		return i == first.size();
	}
	
	public static boolean ordered2(double[] first, double[] second){
		int i = 0;
		for(; i < first.length && i < second.length;i++){
			if(first[i] == second[i]) continue;
			if(first[i] < second[i]) return true;
			return false;
		}
		return i == first.length;
	}
}
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}







Python: >>> [1,2,1,3,2] < [1,2,0,4,4,0,0,0]
False
Task: Order two numerical lists

C: int list_cmp(int *a, int la, int *b, int lb)
{
	int i, l = la;
	if (l > lb) l = lb;
	for (i = 0; i < l; i++) {
		if (a[i] == b[i]) continue;
		return (a[i] > b[i]) ? 1 : -1;
	}
	if (la == lb) return 0;
	return la > lb ? 1 : -1;
}








VB: Private Function order(list1 As Variant, list2 As Variant) As Boolean
    i = 1
    Do While list1(i) <= list2(i)
        i = i + 1
        If i > UBound(list1) Then
            order = True
            Exit Function
        End If
        If i > UBound(list2) Then
            order = False
            Exit Function
        End If
    Loop
    order = False
End Function
Public Sub main()
    Debug.Print order([{1, 2, 3, 4}], [{1,2,0,1,2}])
    Debug.Print order([{1, 2, 3, 4}], [{1,2,3}])
    Debug.Print order([{1, 2, 3}], [{1,2,3,4}])
End Sub
Task: Order two numerical lists


C++: #include <iostream>
#include <vector>

int main() {
  std::vector<int> a;
  a.push_back(1);
  a.push_back(2);
  a.push_back(1);
  a.push_back(3);
  a.push_back(2);
  std::vector<int> b;
  b.push_back(1);
  b.push_back(2);
  b.push_back(0);
  b.push_back(4);
  b.push_back(4);
  b.push_back(0);
  b.push_back(0);
  b.push_back(0);

  std::cout << std::boolalpha << (a < b) << std::endl; 
  return 0;
}


C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}
Task: Order two numerical lists


C++: #include <iostream>
#include <vector>

int main() {
  std::vector<int> a;
  a.push_back(1);
  a.push_back(2);
  a.push_back(1);
  a.push_back(3);
  a.push_back(2);
  std::vector<int> b;
  b.push_back(1);
  b.push_back(2);
  b.push_back(0);
  b.push_back(4);
  b.push_back(4);
  b.push_back(0);
  b.push_back(0);
  b.push_back(0);

  std::cout << std::boolalpha << (a < b) << std::endl; 
  return 0;
}



Go: package main

import "fmt"



func lessRune(a, b []rune) bool {
    return string(a) < string(b) 
}



type numericType int

func lessNT(a, b []numericType) bool {
    l := len(a)
    if len(b) < l {
        l = len(b)
    }
    for i := 0; i < l; i++ {
        if a[i] != b[i] {
            return a[i] < b[i]
        }
    }
    return l < len(b)
}

var testCases = [][][]numericType{
    {{0}, {}},
    {{}, {}},
    {{}, {0}},

    {{-1}, {0}},
    {{0}, {0}},
    {{0}, {-1}},

    {{0}, {0, -1}},
    {{0}, {0, 0}},
    {{0}, {0, 1}},
    {{0, -1}, {0}},
    {{0, 0}, {0}},
    {{0, 0}, {1}},
}

func main() {
    
    for _, tc := range testCases {
        fmt.Printf("order %6s before %6s : %t\n",
            fmt.Sprintf("%v", tc[0]),
            fmt.Sprintf("%v", tc[1]),
            lessNT(tc[0], tc[1]))
    }
    fmt.Println()

    
    
    for _, tc := range testCases {
        a := toByte(tc[0])
        b := toByte(tc[1])
        fmt.Printf("order %6q before %6q : %t\n",
            string(a),
            string(b),
            lessByte(a, b))
    }
}

func toByte(a []numericType) []byte {
    b := make([]byte, len(a))
    for i, n := range a {
        b[i] = 'b' + byte(n)
    }
    return b
}
Task: Order two numerical lists


C++: #include <iostream>
#include <vector>

int main() {
  std::vector<int> a;
  a.push_back(1);
  a.push_back(2);
  a.push_back(1);
  a.push_back(3);
  a.push_back(2);
  std::vector<int> b;
  b.push_back(1);
  b.push_back(2);
  b.push_back(0);
  b.push_back(4);
  b.push_back(4);
  b.push_back(0);
  b.push_back(0);
  b.push_back(0);

  std::cout << std::boolalpha << (a < b) << std::endl; 
  return 0;
}






Python: >>> [1,2,1,3,2] < [1,2,0,4,4,0,0,0]
False
Task: Order two numerical lists


C++: #include <iostream>
#include <vector>

int main() {
  std::vector<int> a;
  a.push_back(1);
  a.push_back(2);
  a.push_back(1);
  a.push_back(3);
  a.push_back(2);
  std::vector<int> b;
  b.push_back(1);
  b.push_back(2);
  b.push_back(0);
  b.push_back(4);
  b.push_back(4);
  b.push_back(0);
  b.push_back(0);
  b.push_back(0);

  std::cout << std::boolalpha << (a < b) << std::endl; 
  return 0;
}







VB: Private Function order(list1 As Variant, list2 As Variant) As Boolean
    i = 1
    Do While list1(i) <= list2(i)
        i = i + 1
        If i > UBound(list1) Then
            order = True
            Exit Function
        End If
        If i > UBound(list2) Then
            order = False
            Exit Function
        End If
    Loop
    order = False
End Function
Public Sub main()
    Debug.Print order([{1, 2, 3, 4}], [{1,2,0,1,2}])
    Debug.Print order([{1, 2, 3, 4}], [{1,2,3}])
    Debug.Print order([{1, 2, 3}], [{1,2,3,4}])
End Sub
Task: Order two numerical lists



C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}


Go: package main

import "fmt"



func lessRune(a, b []rune) bool {
    return string(a) < string(b) 
}



type numericType int

func lessNT(a, b []numericType) bool {
    l := len(a)
    if len(b) < l {
        l = len(b)
    }
    for i := 0; i < l; i++ {
        if a[i] != b[i] {
            return a[i] < b[i]
        }
    }
    return l < len(b)
}

var testCases = [][][]numericType{
    {{0}, {}},
    {{}, {}},
    {{}, {0}},

    {{-1}, {0}},
    {{0}, {0}},
    {{0}, {-1}},

    {{0}, {0, -1}},
    {{0}, {0, 0}},
    {{0}, {0, 1}},
    {{0, -1}, {0}},
    {{0, 0}, {0}},
    {{0, 0}, {1}},
}

func main() {
    
    for _, tc := range testCases {
        fmt.Printf("order %6s before %6s : %t\n",
            fmt.Sprintf("%v", tc[0]),
            fmt.Sprintf("%v", tc[1]),
            lessNT(tc[0], tc[1]))
    }
    fmt.Println()

    
    
    for _, tc := range testCases {
        a := toByte(tc[0])
        b := toByte(tc[1])
        fmt.Printf("order %6q before %6q : %t\n",
            string(a),
            string(b),
            lessByte(a, b))
    }
}

func toByte(a []numericType) []byte {
    b := make([]byte, len(a))
    for i, n := range a {
        b[i] = 'b' + byte(n)
    }
    return b
}
Task: Order two numerical lists



C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}



Java: import java.util.Arrays;
import java.util.List;

public class ListOrder{
	public static boolean ordered(double[] first, double[] second){
		if(first.length == 0) return true;
		if(second.length == 0) return false;
		if(first[0] == second[0])
			return ordered(Arrays.copyOfRange(first, 1, first.length),
					Arrays.copyOfRange(second, 1, second.length));
		return first[0] < second[0];
	}
	
	public static <T extends Comparable<? super T>> boolean ordered(List<T> first, List<T> second){
		int i = 0;
		for(; i < first.size() && i < second.size();i++){
			int cmp = first.get(i).compareTo(second.get(i));
			if(cmp == 0) continue;
			if(cmp < 0) return true;
			return false;
		}
		return i == first.size();
	}
	
	public static boolean ordered2(double[] first, double[] second){
		int i = 0;
		for(; i < first.length && i < second.length;i++){
			if(first[i] == second[i]) continue;
			if(first[i] < second[i]) return true;
			return false;
		}
		return i == first.length;
	}
}
Task: Order two numerical lists



C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}





Python: >>> [1,2,1,3,2] < [1,2,0,4,4,0,0,0]
False
Task: Order two numerical lists



C#: namespace RosettaCode.OrderTwoNumericalLists
{
    using System;
    using System.Collections.Generic;

    internal static class Program
    {
        private static bool IsLessThan(this IEnumerable<int> enumerable,
            IEnumerable<int> otherEnumerable)
        {
            using (
                IEnumerator<int> enumerator = enumerable.GetEnumerator(),
                    otherEnumerator = otherEnumerable.GetEnumerator())
            {
                while (true)
                {
                    if (!otherEnumerator.MoveNext())
                    {
                        return false;
                    }

                    if (!enumerator.MoveNext())
                    {
                        return true;
                    }

                    if (enumerator.Current == otherEnumerator.Current)
                    {
                        continue;
                    }

                    return enumerator.Current < otherEnumerator.Current;
                }
            }
        }

        private static void Main()
        {
            Console.WriteLine(
                new[] {1, 2, 1, 3, 2}.IsLessThan(new[] {1, 2, 0, 4, 4, 0, 0, 0}));
        }
    }
}






VB: Private Function order(list1 As Variant, list2 As Variant) As Boolean
    i = 1
    Do While list1(i) <= list2(i)
        i = i + 1
        If i > UBound(list1) Then
            order = True
            Exit Function
        End If
        If i > UBound(list2) Then
            order = False
            Exit Function
        End If
    Loop
    order = False
End Function
Public Sub main()
    Debug.Print order([{1, 2, 3, 4}], [{1,2,0,1,2}])
    Debug.Print order([{1, 2, 3, 4}], [{1,2,3}])
    Debug.Print order([{1, 2, 3}], [{1,2,3,4}])
End Sub
Task: Order two numerical lists




Go: package main

import "fmt"



func lessRune(a, b []rune) bool {
    return string(a) < string(b) 
}



type numericType int

func lessNT(a, b []numericType) bool {
    l := len(a)
    if len(b) < l {
        l = len(b)
    }
    for i := 0; i < l; i++ {
        if a[i] != b[i] {
            return a[i] < b[i]
        }
    }
    return l < len(b)
}

var testCases = [][][]numericType{
    {{0}, {}},
    {{}, {}},
    {{}, {0}},

    {{-1}, {0}},
    {{0}, {0}},
    {{0}, {-1}},

    {{0}, {0, -1}},
    {{0}, {0, 0}},
    {{0}, {0, 1}},
    {{0, -1}, {0}},
    {{0, 0}, {0}},
    {{0, 0}, {1}},
}

func main() {
    
    for _, tc := range testCases {
        fmt.Printf("order %6s before %6s : %t\n",
            fmt.Sprintf("%v", tc[0]),
            fmt.Sprintf("%v", tc[1]),
            lessNT(tc[0], tc[1]))
    }
    fmt.Println()

    
    
    for _, tc := range testCases {
        a := toByte(tc[0])
        b := toByte(tc[1])
        fmt.Printf("order %6q before %6q : %t\n",
            string(a),
            string(b),
            lessByte(a, b))
    }
}

func toByte(a []numericType) []byte {
    b := make([]byte, len(a))
    for i, n := range a {
        b[i] = 'b' + byte(n)
    }
    return b
}


Java: import java.util.Arrays;
import java.util.List;

public class ListOrder{
	public static boolean ordered(double[] first, double[] second){
		if(first.length == 0) return true;
		if(second.length == 0) return false;
		if(first[0] == second[0])
			return ordered(Arrays.copyOfRange(first, 1, first.length),
					Arrays.copyOfRange(second, 1, second.length));
		return first[0] < second[0];
	}
	
	public static <T extends Comparable<? super T>> boolean ordered(List<T> first, List<T> second){
		int i = 0;
		for(; i < first.size() && i < second.size();i++){
			int cmp = first.get(i).compareTo(second.get(i));
			if(cmp == 0) continue;
			if(cmp < 0) return true;
			return false;
		}
		return i == first.size();
	}
	
	public static boolean ordered2(double[] first, double[] second){
		int i = 0;
		for(; i < first.length && i < second.length;i++){
			if(first[i] == second[i]) continue;
			if(first[i] < second[i]) return true;
			return false;
		}
		return i == first.length;
	}
}
Task: Order two numerical lists





Java: import java.util.Arrays;
import java.util.List;

public class ListOrder{
	public static boolean ordered(double[] first, double[] second){
		if(first.length == 0) return true;
		if(second.length == 0) return false;
		if(first[0] == second[0])
			return ordered(Arrays.copyOfRange(first, 1, first.length),
					Arrays.copyOfRange(second, 1, second.length));
		return first[0] < second[0];
	}
	
	public static <T extends Comparable<? super T>> boolean ordered(List<T> first, List<T> second){
		int i = 0;
		for(; i < first.size() && i < second.size();i++){
			int cmp = first.get(i).compareTo(second.get(i));
			if(cmp == 0) continue;
			if(cmp < 0) return true;
			return false;
		}
		return i == first.size();
	}
	
	public static boolean ordered2(double[] first, double[] second){
		int i = 0;
		for(; i < first.length && i < second.length;i++){
			if(first[i] == second[i]) continue;
			if(first[i] < second[i]) return true;
			return false;
		}
		return i == first.length;
	}
}



Python: >>> [1,2,1,3,2] < [1,2,0,4,4,0,0,0]
False
Task: Order two numerical lists





Java: import java.util.Arrays;
import java.util.List;

public class ListOrder{
	public static boolean ordered(double[] first, double[] second){
		if(first.length == 0) return true;
		if(second.length == 0) return false;
		if(first[0] == second[0])
			return ordered(Arrays.copyOfRange(first, 1, first.length),
					Arrays.copyOfRange(second, 1, second.length));
		return first[0] < second[0];
	}
	
	public static <T extends Comparable<? super T>> boolean ordered(List<T> first, List<T> second){
		int i = 0;
		for(; i < first.size() && i < second.size();i++){
			int cmp = first.get(i).compareTo(second.get(i));
			if(cmp == 0) continue;
			if(cmp < 0) return true;
			return false;
		}
		return i == first.size();
	}
	
	public static boolean ordered2(double[] first, double[] second){
		int i = 0;
		for(; i < first.length && i < second.length;i++){
			if(first[i] == second[i]) continue;
			if(first[i] < second[i]) return true;
			return false;
		}
		return i == first.length;
	}
}




VB: Private Function order(list1 As Variant, list2 As Variant) As Boolean
    i = 1
    Do While list1(i) <= list2(i)
        i = i + 1
        If i > UBound(list1) Then
            order = True
            Exit Function
        End If
        If i > UBound(list2) Then
            order = False
            Exit Function
        End If
    Loop
    order = False
End Function
Public Sub main()
    Debug.Print order([{1, 2, 3, 4}], [{1,2,0,1,2}])
    Debug.Print order([{1, 2, 3, 4}], [{1,2,3}])
    Debug.Print order([{1, 2, 3}], [{1,2,3,4}])
End Sub