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;
}



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<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;
}


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

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;
}




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: #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;
}





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

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;
}







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

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;
}








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


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";
}


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";
}



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++: #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";
}




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


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";
}






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


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";
}







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



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(". "));


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(". "));



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



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(". "));





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



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(". "));






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(". "))
}


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





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(". "));
        }
    }



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




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(". "))
}




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




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(". "))
}





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







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(". "))


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





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(". "));
        }
    }




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

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;
}






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



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(". "));




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


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";
}





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




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(". "))
}



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





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(". "));
        }
    }


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(". ");
?>


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






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(". ");
?>



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