kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}

Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }
Task: Higher-order functions
C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}

Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}
Task: Higher-order functions
Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }

Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}
Task: Higher-order functions
Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }

Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)
Task: Higher-order functions
Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}
Task: Higher-order functions
C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)
Task: Higher-order functions
C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}

Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module
Task: Higher-order functions
Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}

Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)
Task: Higher-order functions
C: void myFuncSimple( void (*funcParameter)(void) )
{
    
   
    (*funcParameter)();  
    funcParameter();     

    
}

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
C#: using System;


delegate int Func2(int a, int b);

class Program
{
    static int Add(int a, int b)
    {
        return a + b;
    }
    
    static int Mul(int a, int b)
    {
        return a * b;
    }
    
    static int Div(int a, int b)
    {
        return a / b;
    }
    
    static int Call(Func2 f, int a, int b)
    {
        
        return f(a, b);
    }

    static void Main()
    {
        int a = 6;
        int b = 2;

        
        Func2 add = new Func2(Add);
        Func2 mul = new Func2(Mul);
        Func2 div = new Func2(Div);
        
        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, Call(add, a, b));
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, Call(mul, a, b));
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, Call(div, a, b));
    }
}

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
C++: 
#include <tr1/functional>
#include <iostream>

using namespace std;
using namespace std::tr1;

void first(function<void()> f)
{
  f();
}

void second()
{
  cout << "second\n";
}

int main()
{
  first(second);
}

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
Go: package main
import "fmt"

func func1(f func(string) string) string { return f("a string") }
func func2(s string) string { return "func2 called with " + s }
func main() { fmt.Println(func1(func2)) }

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
Java: public class NewClass {
   
   public NewClass() {
       first(new AnEventOrCallback() {
           public void call() {
               second();
           }
       });
   }
   
   public void first(AnEventOrCallback obj) {
       obj.call();
   }
   
   public void second() {
       System.out.println("Second");
   }
   
   public static void main(String[] args) {
       new NewClass();
   }
}

interface AnEventOrCallback {
   public void call();
}

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
Python: def first(function):
    return function()

def second():
    return "second"

result = first(second)

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Higher-order functions
VB: 
Delegate Function Func2(a As Integer, b As Integer) As Integer

Module Program
    Function Add(a As Integer, b As Integer) As Integer
        Return a + b
    End Function

    Function Mul(a As Integer, b As Integer) As Integer
        Return a * b
    End Function

    Function Div(a As Integer, b As Integer) As Integer
        Return a \ b
    End Function

    
    Function [Call](f As Func2, a As Integer, b As Integer) As Integer
        Return f(a, b)
    End Function

    Sub Main()
        Dim a = 6
        Dim b = 2

        
        Dim add As Func2 = New Func2(AddressOf Program.Add)

        
        Dim div As New Func2(AddressOf Program.Div)

        
        Dim mul As Func2 = AddressOf Program.Mul

        Console.WriteLine("f=Add, f({0}, {1}) = {2}", a, b, [Call](add, a, b))
        Console.WriteLine("f=Mul, f({0}, {1}) = {2}", a, b, [Call](mul, a, b))
        Console.WriteLine("f=Div, f({0}, {1}) = {2}", a, b, [Call](div, a, b))
    End Sub
End Module

PHP: function first($func) {
  return $func();
}

function second() {
  return 'second';
}

$result = first('second');
Task: Ackermann function
C: #include <stdio.h>

int ackermann(int m, int n)
{
        if (!m) return n + 1;
        if (!n) return ackermann(m - 1, 1);
        return ackermann(m - 1, ackermann(m, n - 1));
}

int main()
{
        int m, n;
        for (m = 0; m <= 4; m++)
                for (n = 0; n < 6 - m; n++)
                        printf("A(%d, %d) = %d\n", m, n, ackermann(m, n));

        return 0;
}

C#: using System;
class Program
{
    public static long Ackermann(long m, long n)
    {
        if(m > 0)
        {
            if (n > 0)
                return Ackermann(m - 1, Ackermann(m, n - 1));
            else if (n == 0)
                return Ackermann(m - 1, 1);
        }
        else if(m == 0)
        {
            if(n >= 0) 
                return n + 1;
        }

        throw new System.ArgumentOutOfRangeException();
    }
    
    static void Main()
    {
        for (long m = 0; m <= 3; ++m)
        {
            for (long n = 0; n <= 4; ++n)
            {
                Console.WriteLine("Ackermann({0}, {1}) = {2}", m, n, Ackermann(m, n));
            }
        }
    }
}
Task: Ackermann function
C: #include <stdio.h>

int ackermann(int m, int n)
{
        if (!m) return n + 1;
        if (!n) return ackermann(m - 1, 1);
        return ackermann(m - 1, ackermann(m, n - 1));
}

int main()
{
        int m, n;
        for (m = 0; m <= 4; m++)
                for (n = 0; n < 6 - m; n++)
                        printf("A(%d, %d) = %d\n", m, n, ackermann(m, n));

        return 0;
}

C++: #include <iostream>

unsigned int ackermann(unsigned int m, unsigned int n) {
  if (m == 0) {
    return n + 1;
  }
  if (n == 0) {
    return ackermann(m - 1, 1);
  }
  return ackermann(m - 1, ackermann(m, n - 1));
}

int main() {
  for (unsigned int m = 0; m < 4; ++m) {
    for (unsigned int n = 0; n < 10; ++n) {
      std::cout << "A(" << m << ", " << n << ") = " << ackermann(m, n) << "\n";
    }
  }
}
Task: Ackermann function
C: #include <stdio.h>

int ackermann(int m, int n)
{
        if (!m) return n + 1;
        if (!n) return ackermann(m - 1, 1);
        return ackermann(m - 1, ackermann(m, n - 1));
}

int main()
{
        int m, n;
        for (m = 0; m <= 4; m++)
                for (n = 0; n < 6 - m; n++)
                        printf("A(%d, %d) = %d\n", m, n, ackermann(m, n));

        return 0;
}

Java: import java.math.BigInteger;

public static BigInteger ack(BigInteger m, BigInteger n) {
    return m.equals(BigInteger.ZERO)
            ? n.add(BigInteger.ONE)
            : ack(m.subtract(BigInteger.ONE),
                        n.equals(BigInteger.ZERO) ? BigInteger.ONE : ack(m, n.subtract(BigInteger.ONE)));
}