kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Gauss-Jordan matrix inversion
Go: package main

import "fmt"

type vector = []float64
type matrix []vector

func (m matrix) inverse() matrix {
    le := len(m)
    for _, v := range m {
        if len(v) != le {
            panic("Not a square matrix")
        }
    }
    aug := make(matrix, le)
    for i := 0; i < le; i++ {
        aug[i] = make(vector, 2*le)
        copy(aug[i], m[i])
        
        aug[i][i+le] = 1
    }
    aug.toReducedRowEchelonForm()
    inv := make(matrix, le)
    
    for i := 0; i < le; i++ {
        inv[i] = make(vector, le)
        copy(inv[i], aug[i][le:])
    }
    return inv
}


func (m matrix) toReducedRowEchelonForm() {
    lead := 0
    rowCount, colCount := len(m), len(m[0])
    for r := 0; r < rowCount; r++ {
        if colCount <= lead {
            return
        }
        i := r

        for m[i][lead] == 0 {
            i++
            if rowCount == i {
                i = r
                lead++
                if colCount == lead {
                    return
                }
            }
        }

        m[i], m[r] = m[r], m[i]
        if div := m[r][lead]; div != 0 {
            for j := 0; j < colCount; j++ {
                m[r][j] /= div
            }
        }

        for k := 0; k < rowCount; k++ {
            if k != r {
                mult := m[k][lead]
                for j := 0; j < colCount; j++ {
                    m[k][j] -= m[r][j] * mult
                }
            }
        }
        lead++
    }
}

func (m matrix) print(title string) {
    fmt.Println(title)
    for _, v := range m {
        fmt.Printf("% f\n", v)
    }
    fmt.Println()
}

func main() {
    a := matrix{{1, 2, 3}, {4, 1, 6}, {7, 8, 9}}
    a.inverse().print("Inverse of A is:\n")

    b := matrix{{2, -1, 0}, {-1, 2, -1}, {0, -1, 2}}
    b.inverse().print("Inverse of B is:\n")
}

Python: import numpy as np
from numpy.linalg import inv
a = np.array([[1., 2., 3.], [4., 1., 6.],[ 7., 8., 9.]])
ainv = inv(a)

print(a)
print(ainv)
Task: Gauss-Jordan matrix inversion
Go: package main

import "fmt"

type vector = []float64
type matrix []vector

func (m matrix) inverse() matrix {
    le := len(m)
    for _, v := range m {
        if len(v) != le {
            panic("Not a square matrix")
        }
    }
    aug := make(matrix, le)
    for i := 0; i < le; i++ {
        aug[i] = make(vector, 2*le)
        copy(aug[i], m[i])
        
        aug[i][i+le] = 1
    }
    aug.toReducedRowEchelonForm()
    inv := make(matrix, le)
    
    for i := 0; i < le; i++ {
        inv[i] = make(vector, le)
        copy(inv[i], aug[i][le:])
    }
    return inv
}


func (m matrix) toReducedRowEchelonForm() {
    lead := 0
    rowCount, colCount := len(m), len(m[0])
    for r := 0; r < rowCount; r++ {
        if colCount <= lead {
            return
        }
        i := r

        for m[i][lead] == 0 {
            i++
            if rowCount == i {
                i = r
                lead++
                if colCount == lead {
                    return
                }
            }
        }

        m[i], m[r] = m[r], m[i]
        if div := m[r][lead]; div != 0 {
            for j := 0; j < colCount; j++ {
                m[r][j] /= div
            }
        }

        for k := 0; k < rowCount; k++ {
            if k != r {
                mult := m[k][lead]
                for j := 0; j < colCount; j++ {
                    m[k][j] -= m[r][j] * mult
                }
            }
        }
        lead++
    }
}

func (m matrix) print(title string) {
    fmt.Println(title)
    for _, v := range m {
        fmt.Printf("% f\n", v)
    }
    fmt.Println()
}

func main() {
    a := matrix{{1, 2, 3}, {4, 1, 6}, {7, 8, 9}}
    a.inverse().print("Inverse of A is:\n")

    b := matrix{{2, -1, 0}, {-1, 2, -1}, {0, -1, 2}}
    b.inverse().print("Inverse of B is:\n")
}

VB: Private Function inverse(mat As Variant) As Variant
    Dim len_ As Integer: len_ = UBound(mat)
    Dim tmp() As Variant
    ReDim tmp(2 * len_ + 1)
    Dim aug As Variant
    ReDim aug(len_)
    For i = 0 To len_
        If UBound(mat(i)) <> len_ Then Debug.Print 9 / 0 
        aug(i) = tmp
        For j = 0 To len_
            aug(i)(j) = mat(i)(j)
        Next j
        
        aug(i)(i + len_ + 1) = 1
    Next i
    aug = ToReducedRowEchelonForm(aug)
    Dim inv As Variant
    inv = mat
    
    For i = 0 To len_
        For j = len_ + 1 To 2 * len_ + 1
            inv(i)(j - len_ - 1) = aug(i)(j)
        Next j
    Next i
    inverse = inv
End Function
 
Public Sub main()
    Dim test As Variant
    test = inverse(Array( _
        Array(2, -1, 0), _
        Array(-1, 2, -1), _
        Array(0, -1, 2)))
    For i = LBound(test) To UBound(test)
        For j = LBound(test(0)) To UBound(test(0))
            Debug.Print test(i)(j),
        Next j
    Debug.Print
    Next i
End Sub
Task: Gauss-Jordan matrix inversion
Python: import numpy as np
from numpy.linalg import inv
a = np.array([[1., 2., 3.], [4., 1., 6.],[ 7., 8., 9.]])
ainv = inv(a)

print(a)
print(ainv)

VB: Private Function inverse(mat As Variant) As Variant
    Dim len_ As Integer: len_ = UBound(mat)
    Dim tmp() As Variant
    ReDim tmp(2 * len_ + 1)
    Dim aug As Variant
    ReDim aug(len_)
    For i = 0 To len_
        If UBound(mat(i)) <> len_ Then Debug.Print 9 / 0 
        aug(i) = tmp
        For j = 0 To len_
            aug(i)(j) = mat(i)(j)
        Next j
        
        aug(i)(i + len_ + 1) = 1
    Next i
    aug = ToReducedRowEchelonForm(aug)
    Dim inv As Variant
    inv = mat
    
    For i = 0 To len_
        For j = len_ + 1 To 2 * len_ + 1
            inv(i)(j - len_ - 1) = aug(i)(j)
        Next j
    Next i
    inverse = inv
End Function
 
Public Sub main()
    Dim test As Variant
    test = inverse(Array( _
        Array(2, -1, 0), _
        Array(-1, 2, -1), _
        Array(0, -1, 2)))
    For i = LBound(test) To UBound(test)
        For j = LBound(test(0)) To UBound(test(0))
            Debug.Print test(i)(j),
        Next j
    Debug.Print
    Next i
End Sub
Task: Gauss-Jordan matrix inversion
C: 
#include <math.h>
int gjinv (double *a, int n, double *b)
{
	int i, j, k, p;
	double f, g, tol;
	if (n < 1) return -1;  
	f = 0.;  
	for (i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			g = a[j+i*n];
			f += g * g;
		}
	}
	f = sqrt(f);
	tol = f * 2.2204460492503131e-016;
	for (i = 0; i < n; ++i) {  
		for (j = 0; j < n; ++j) {
			b[j+i*n] = (i == j) ? 1. : 0.;
		}
	}
	for (k = 0; k < n; ++k) {  
		f = fabs(a[k+k*n]);  
		p = k;
		for (i = k+1; i < n; ++i) {
			g = fabs(a[k+i*n]);
			if (g > f) {
				f = g;
				p = i;
			}
		}
		if (f < tol) return 1;  
		if (p != k) {  
			for (j = k; j < n; ++j) {
				f = a[j+k*n];
				a[j+k*n] = a[j+p*n];
				a[j+p*n] = f;
			}
			for (j = 0; j < n; ++j) {
				f = b[j+k*n];
				b[j+k*n] = b[j+p*n];
				b[j+p*n] = f;
			}
		}
		f = 1. / a[k+k*n];  
		for (j = k; j < n; ++j) a[j+k*n] *= f;
		for (j = 0; j < n; ++j) b[j+k*n] *= f;
		for (i = 0; i < n; ++i) {  
			if (i == k) continue;
			f = a[k+i*n];
			for (j = k; j < n; ++j) a[j+i*n] -= a[j+k*n] * f;
			for (j = 0; j < n; ++j) b[j+i*n] -= b[j+k*n] * f;
		}
	}
	return 0;
} 

Go: package main

import "fmt"

type vector = []float64
type matrix []vector

func (m matrix) inverse() matrix {
    le := len(m)
    for _, v := range m {
        if len(v) != le {
            panic("Not a square matrix")
        }
    }
    aug := make(matrix, le)
    for i := 0; i < le; i++ {
        aug[i] = make(vector, 2*le)
        copy(aug[i], m[i])
        
        aug[i][i+le] = 1
    }
    aug.toReducedRowEchelonForm()
    inv := make(matrix, le)
    
    for i := 0; i < le; i++ {
        inv[i] = make(vector, le)
        copy(inv[i], aug[i][le:])
    }
    return inv
}


func (m matrix) toReducedRowEchelonForm() {
    lead := 0
    rowCount, colCount := len(m), len(m[0])
    for r := 0; r < rowCount; r++ {
        if colCount <= lead {
            return
        }
        i := r

        for m[i][lead] == 0 {
            i++
            if rowCount == i {
                i = r
                lead++
                if colCount == lead {
                    return
                }
            }
        }

        m[i], m[r] = m[r], m[i]
        if div := m[r][lead]; div != 0 {
            for j := 0; j < colCount; j++ {
                m[r][j] /= div
            }
        }

        for k := 0; k < rowCount; k++ {
            if k != r {
                mult := m[k][lead]
                for j := 0; j < colCount; j++ {
                    m[k][j] -= m[r][j] * mult
                }
            }
        }
        lead++
    }
}

func (m matrix) print(title string) {
    fmt.Println(title)
    for _, v := range m {
        fmt.Printf("% f\n", v)
    }
    fmt.Println()
}

func main() {
    a := matrix{{1, 2, 3}, {4, 1, 6}, {7, 8, 9}}
    a.inverse().print("Inverse of A is:\n")

    b := matrix{{2, -1, 0}, {-1, 2, -1}, {0, -1, 2}}
    b.inverse().print("Inverse of B is:\n")
}
Task: Closures_Value capture
C#: using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var captor = (Func<int, Func<int>>)(number => () => number * number);
        var functions = Enumerable.Range(0, 10).Select(captor);
        foreach (var function in functions.Take(9))
        {
            Console.WriteLine(function());
        }
    }
}

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

int main() {
  std::vector<std::function<int()> > funcs;
  for (int i = 0; i < 10; i++)
    funcs.push_back([=]() { return i * i; });
  for ( std::function<int( )> f : funcs ) 
    std::cout << f( ) << std::endl ; 
  return 0;
}
Task: Closures_Value capture
C++: #include <iostream>
#include <functional>
#include <vector>

int main() {
  std::vector<std::function<int()> > funcs;
  for (int i = 0; i < 10; i++)
    funcs.push_back([=]() { return i * i; });
  for ( std::function<int( )> f : funcs ) 
    std::cout << f( ) << std::endl ; 
  return 0;
}

Python: funcs = []
for i in range(10):
    funcs.append(lambda: i * i)
print funcs[3]()
Task: Closures_Value capture
C#: using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var captor = (Func<int, Func<int>>)(number => () => number * number);
        var functions = Enumerable.Range(0, 10).Select(captor);
        foreach (var function in functions.Take(9))
        {
            Console.WriteLine(function());
        }
    }
}

Java: import java.util.function.Supplier;
import java.util.ArrayList;

public class ValueCapture {
    public static void main(String[] args) {
	ArrayList<Supplier<Integer>> funcs = new ArrayList<>();
	for (int i = 0; i < 10; i++) {
	    int j = i;
	    funcs.add(() -> j * j);
	}

	Supplier<Integer> foo = funcs.get(3);
	System.out.println(foo.get()); 
    }
}
Task: Closures_Value capture
C#: using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var captor = (Func<int, Func<int>>)(number => () => number * number);
        var functions = Enumerable.Range(0, 10).Select(captor);
        foreach (var function in functions.Take(9))
        {
            Console.WriteLine(function());
        }
    }
}

Python: funcs = []
for i in range(10):
    funcs.append(lambda: i * i)
print funcs[3]()
Task: Closures_Value capture
Java: import java.util.function.Supplier;
import java.util.ArrayList;

public class ValueCapture {
    public static void main(String[] args) {
	ArrayList<Supplier<Integer>> funcs = new ArrayList<>();
	for (int i = 0; i < 10; i++) {
	    int j = i;
	    funcs.add(() -> j * j);
	}

	Supplier<Integer> foo = funcs.get(3);
	System.out.println(foo.get()); 
    }
}

Python: funcs = []
for i in range(10):
    funcs.append(lambda: i * i)
print funcs[3]()
Task: Closures_Value capture
C++: #include <iostream>
#include <functional>
#include <vector>

int main() {
  std::vector<std::function<int()> > funcs;
  for (int i = 0; i < 10; i++)
    funcs.push_back([=]() { return i * i; });
  for ( std::function<int( )> f : funcs ) 
    std::cout << f( ) << std::endl ; 
  return 0;
}

Java: import java.util.function.Supplier;
import java.util.ArrayList;

public class ValueCapture {
    public static void main(String[] args) {
	ArrayList<Supplier<Integer>> funcs = new ArrayList<>();
	for (int i = 0; i < 10; i++) {
	    int j = i;
	    funcs.add(() -> j * j);
	}

	Supplier<Integer> foo = funcs.get(3);
	System.out.println(foo.get()); 
    }
}
Task: Remove vowels from a string
C: #include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}

C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}
Task: Remove vowels from a string
C: #include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}

Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}
Task: Remove vowels from a string
C: #include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}

Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string
C: #include <stdio.h>

void print_no_vowels(const char *s) {
    for (; *s != 0; s++) {
        switch (*s) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            break;
        default:
            putchar(*s);
            break;
        }
    }
}

void test(const char *const s) {
    printf("Input  : %s\n", s);

    printf("Output : ");
    print_no_vowels(s);
    printf("\n");
}

int main() {
    test("C Programming Language");
    return 0;
}

VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Remove vowels from a string
C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}

Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}
Task: Remove vowels from a string
C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}

Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}
Task: Remove vowels from a string
C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}

Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string
C#: static string remove_vowels(string value)
{
    var stripped = from c in value.ToCharArray()
                   where !"aeiouAEIOU".Contains(c)
                   select c;

    return new string(stripped.ToArray());
}

static void test(string value)
{
    Console.WriteLine("Input:  " + value);
    Console.WriteLine("Output: " + remove_vowels(value));
}

static void Main(string[] args)
{
    test("CSharp Programming Language");
}

VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module
Task: Remove vowels from a string
Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}

Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}
Task: Remove vowels from a string
Java: public static String removeVowelse(String str){
    String re = "";
    char c;
    for(int x = 0; x<str.length(); x++){
        c = str.charAt(x);
        if(!(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'))
        re+=c;
    }
    return re;
}

Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string
Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}

Python: 



def exceptGlyphs(exclusions):
    
    def go(s):
        return ''.join(
            c for c in s if c not in exclusions
        )
    return go




def main():
    

    txt = 

    print(
        exceptGlyphs('eau')(txt)
    )



if __name__ == '__main__':
    main()
Task: Remove vowels from a string
Go: package main

import (
    "fmt"
    "strings"
)

func removeVowels(s string) string {
    var sb strings.Builder
    vowels := "aeiouAEIOU"
    for _, c := range s {
        if !strings.ContainsAny(string(c), vowels) {
            sb.WriteRune(c)
        }
    }
    return sb.String()
}

func main() {
    s := "Go Programming Language"
    fmt.Println("Input  :", s)
    fmt.Println("Output :", removeVowels(s))
}

VB: Imports System.Text

Module Module1

    Function RemoveVowels(s As String) As String
        Dim sb As New StringBuilder
        For Each c In s
            Select Case c
                Case "A", "a"
                Case "E", "e"
                Case "I", "i"
                Case "O", "o"
                Case "U", "u"
                    Exit Select
                Case Else
                    sb.Append(c)
            End Select
        Next
        Return sb.ToString
    End Function

    Sub Test(s As String)
        Console.WriteLine("Input  : {0}", s)
        Console.WriteLine("Output : {0}", RemoveVowels(s))
    End Sub

    Sub Main()
        Test("Visual Basic .NET")
    End Sub

End Module