kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Farey sequence
C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

void farey(int n)
{
	typedef struct { int d, n; } frac;
	frac f1 = {0, 1}, f2 = {1, n}, t;
	int k;

	printf("%d/%d %d/%d", 0, 1, 1, n);
	while (f2.n > 1) {
		k = (n + f1.n) / f2.n;
		t = f1, f1 = f2, f2 = (frac) { f2.d * k - t.d, f2.n * k - t.n };
		printf(" %d/%d", f2.d, f2.n);
	}

	putchar('\n');
}

typedef unsigned long long ull;
ull *cache;
size_t ccap;

ull farey_len(int n)
{
	if (n >= ccap) {
		size_t old = ccap;
		if (!ccap) ccap = 16;
		while (ccap <= n) ccap *= 2;
		cache = realloc(cache, sizeof(ull) * ccap);
		memset(cache + old, 0, sizeof(ull) * (ccap - old));
	} else if (cache[n])
		return cache[n];

	ull len = (ull)n*(n + 3) / 2;
	int p, q = 0;
	for (p = 2; p <= n; p = q) {
		q = n/(n/p) + 1;
		len -= farey_len(n/p) * (q - p);
	}

	cache[n] = len;
	return len;
}

int main(void)
{
	int n;
	for (n = 1; n <= 11; n++) {
		printf("%d: ", n);
		farey(n);
	}

	for (n = 100; n <= 1000; n += 100)
		printf("%d: %llu items\n", n, farey_len(n));

	n = 10000000;
	printf("\n%d: %llu items\n", n, farey_len(n));
	return 0;
}

Go: package main

import "fmt"

type frac struct{ num, den int }

func (f frac) String() string {
    return fmt.Sprintf("%d/%d", f.num, f.den)
}

func f(l, r frac, n int) {
    m := frac{l.num + r.num, l.den + r.den}
    if m.den <= n {
        f(l, m, n)
        fmt.Print(m, " ")
        f(m, r, n)
    }
}

func main() {
    
    for n := 1; n <= 11; n++ {
        l := frac{0, 1}
        r := frac{1, 1}
        fmt.Printf("F(%d): %s ", n, l)
        f(l, r, n)
        fmt.Println(r)
    }
    
    
    var composite [1001]bool
    for _, p := range []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31} {
        for n := p * 2; n <= 1000; n += p {
            composite[n] = true
        }
    }
    
    var tot [1001]int
    for i := range tot {
        tot[i] = 1
    }
    for n := 2; n <= 1000; n++ {
        if !composite[n] {
            tot[n] = n - 1
            for a := n * 2; a <= 1000; a += n {
                f := n - 1
                for r := a / n; r%n == 0; r /= n {
                    f *= n
                }
                tot[a] *= f
            }
        }
    }
    
    for n, sum := 1, 1; n <= 1000; n++ {
        sum += tot[n]
        if n%100 == 0 {
            fmt.Printf("|F(%d)|: %d\n", n, sum)
        }
    }
}
Task: Farey sequence
Java: import java.util.TreeSet;

public class Farey{
	private static class Frac implements Comparable<Frac>{
		int num;
		int den;
		
		public Frac(int num, int den){
			this.num = num;
			this.den = den;
		}

		@Override
		public String toString(){
			return num + "/" + den;
		}

		@Override
		public int compareTo(Frac o){
			return Double.compare((double)num / den, (double)o.num / o.den);
		}
	}
	
	public static TreeSet<Frac> genFarey(int i){
		TreeSet<Frac> farey = new TreeSet<Frac>();
		for(int den = 1; den <= i; den++){
			for(int num = 0; num <= den; num++){
				farey.add(new Frac(num, den));
			}
		}
		return farey;
	}
	
	public static void main(String[] args){
		for(int i = 1; i <= 11; i++){
			System.out.println("F" + i + ": " + genFarey(i));
		}
		
		for(int i = 100; i <= 1000; i += 100){
			System.out.println("F" + i + ": " + genFarey(i).size() + " members");
		}
	}
}

Python: from fractions import Fraction


class Fr(Fraction):
    def __repr__(self):
        return '(%s/%s)' % (self.numerator, self.denominator)


def farey(n, length=False):
    if not length:
        return [Fr(0, 1)] + sorted({Fr(m, k) for k in range(1, n+1) for m in range(1, k+1)})
    else:
        
        return  (n*(n+3))//2 - sum(farey(n//k, True) for k in range(2, n+1))
        
if __name__ == '__main__':
    print('Farey sequence for order 1 through 11 (inclusive):')
    for n in range(1, 12): 
        print(farey(n))
    print('Number of fractions in the Farey sequence for order 100 through 1,000 (inclusive) by hundreds:')
    print([farey(i, length=True) for i in range(100, 1001, 100)])
Task: First power of 2 that has leading decimal digits of 12
C: #include <math.h>
#include <stdio.h>

int p(int l, int n) {
    int test = 0;
    double logv = log(2.0) / log(10.0);
    int factor = 1;
    int loop = l;
    while (loop > 10) {
        factor *= 10;
        loop /= 10;
    }
    while (n > 0) {
        int val;

        test++;
        val = (int)(factor * pow(10.0, fmod(test * logv, 1)));
        if (val == l) {
            n--;
        }
    }
    return test;
}

void runTest(int l, int n) {
    printf("p(%d, %d) = %d\n", l, n, p(l, n));
}

int main() {
    runTest(12, 1);
    runTest(12, 2);
    runTest(123, 45);
    runTest(123, 12345);
    runTest(123, 678910);

    return 0;
}

Go: package main

import (
    "fmt"
    "math"
    "time"
)

const ld10 = math.Ln2 / math.Ln10

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func p(L, n uint64) uint64 {
    i := L
    digits := uint64(1)
    for i >= 10 {
        digits *= 10
        i /= 10
    }
    count := uint64(0)
    for i = 0; count < n; i++ {
        e := math.Exp(math.Ln10 * math.Mod(float64(i)*ld10, 1))
        if uint64(math.Trunc(e*float64(digits))) == L {
            count++            
        }
    }
    return i - 1
}

func main() {
    start := time.Now()
    params := [][2]uint64{{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}}
    for _, param := range params {
        fmt.Printf("p(%d, %d) = %s\n", param[0], param[1], commatize(p(param[0], param[1])))
    }
    fmt.Printf("\nTook %s\n", time.Since(start))
}
Task: First power of 2 that has leading decimal digits of 12
C: #include <math.h>
#include <stdio.h>

int p(int l, int n) {
    int test = 0;
    double logv = log(2.0) / log(10.0);
    int factor = 1;
    int loop = l;
    while (loop > 10) {
        factor *= 10;
        loop /= 10;
    }
    while (n > 0) {
        int val;

        test++;
        val = (int)(factor * pow(10.0, fmod(test * logv, 1)));
        if (val == l) {
            n--;
        }
    }
    return test;
}

void runTest(int l, int n) {
    printf("p(%d, %d) = %d\n", l, n, p(l, n));
}

int main() {
    runTest(12, 1);
    runTest(12, 2);
    runTest(123, 45);
    runTest(123, 12345);
    runTest(123, 678910);

    return 0;
}

Java: public class FirstPowerOfTwo {

    public static void main(String[] args) {
        runTest(12, 1);
        runTest(12, 2);
        runTest(123, 45);
        runTest(123, 12345);
        runTest(123, 678910);
    }
    
    private static void runTest(int l, int n) {
        System.out.printf("p(%d, %d) = %,d%n", l, n, p(l, n));
    }
    
    public static int p(int l, int n) {
        int test = 0;
        double log = Math.log(2) / Math.log(10);
        int factor = 1;
        int loop = l;
        while ( loop > 10 ) {
            factor *= 10;
            loop /= 10;
        }
        while ( n > 0) {
            test++;
            int val = (int) (factor * Math.pow(10, test * log % 1));
            if ( val == l ) {
                n--;
            }
        }
        return test;
    }
    
}
Task: First power of 2 that has leading decimal digits of 12
C: #include <math.h>
#include <stdio.h>

int p(int l, int n) {
    int test = 0;
    double logv = log(2.0) / log(10.0);
    int factor = 1;
    int loop = l;
    while (loop > 10) {
        factor *= 10;
        loop /= 10;
    }
    while (n > 0) {
        int val;

        test++;
        val = (int)(factor * pow(10.0, fmod(test * logv, 1)));
        if (val == l) {
            n--;
        }
    }
    return test;
}

void runTest(int l, int n) {
    printf("p(%d, %d) = %d\n", l, n, p(l, n));
}

int main() {
    runTest(12, 1);
    runTest(12, 2);
    runTest(123, 45);
    runTest(123, 12345);
    runTest(123, 678910);

    return 0;
}

Python: from math import log, modf, floor

def p(l, n, pwr=2):
    l = int(abs(l))
    digitcount = floor(log(l, 10))
    log10pwr = log(pwr, 10)
    raised, found = -1, 0
    while found < n:
        raised += 1
        firstdigits = floor(10**(modf(log10pwr * raised)[0] + digitcount))
        if firstdigits == l:
            found += 1
    return raised


if __name__ == '__main__':
    for l, n in [(12, 1), (12, 2), (123, 45), (123, 12345), (123, 678910)]:
        print(f"p({l}, {n}) =", p(l, n))
Task: First power of 2 that has leading decimal digits of 12
Go: package main

import (
    "fmt"
    "math"
    "time"
)

const ld10 = math.Ln2 / math.Ln10

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func p(L, n uint64) uint64 {
    i := L
    digits := uint64(1)
    for i >= 10 {
        digits *= 10
        i /= 10
    }
    count := uint64(0)
    for i = 0; count < n; i++ {
        e := math.Exp(math.Ln10 * math.Mod(float64(i)*ld10, 1))
        if uint64(math.Trunc(e*float64(digits))) == L {
            count++            
        }
    }
    return i - 1
}

func main() {
    start := time.Now()
    params := [][2]uint64{{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}}
    for _, param := range params {
        fmt.Printf("p(%d, %d) = %s\n", param[0], param[1], commatize(p(param[0], param[1])))
    }
    fmt.Printf("\nTook %s\n", time.Since(start))
}

Java: public class FirstPowerOfTwo {

    public static void main(String[] args) {
        runTest(12, 1);
        runTest(12, 2);
        runTest(123, 45);
        runTest(123, 12345);
        runTest(123, 678910);
    }
    
    private static void runTest(int l, int n) {
        System.out.printf("p(%d, %d) = %,d%n", l, n, p(l, n));
    }
    
    public static int p(int l, int n) {
        int test = 0;
        double log = Math.log(2) / Math.log(10);
        int factor = 1;
        int loop = l;
        while ( loop > 10 ) {
            factor *= 10;
            loop /= 10;
        }
        while ( n > 0) {
            test++;
            int val = (int) (factor * Math.pow(10, test * log % 1));
            if ( val == l ) {
                n--;
            }
        }
        return test;
    }
    
}
Task: First power of 2 that has leading decimal digits of 12
Java: public class FirstPowerOfTwo {

    public static void main(String[] args) {
        runTest(12, 1);
        runTest(12, 2);
        runTest(123, 45);
        runTest(123, 12345);
        runTest(123, 678910);
    }
    
    private static void runTest(int l, int n) {
        System.out.printf("p(%d, %d) = %,d%n", l, n, p(l, n));
    }
    
    public static int p(int l, int n) {
        int test = 0;
        double log = Math.log(2) / Math.log(10);
        int factor = 1;
        int loop = l;
        while ( loop > 10 ) {
            factor *= 10;
            loop /= 10;
        }
        while ( n > 0) {
            test++;
            int val = (int) (factor * Math.pow(10, test * log % 1));
            if ( val == l ) {
                n--;
            }
        }
        return test;
    }
    
}

Python: from math import log, modf, floor

def p(l, n, pwr=2):
    l = int(abs(l))
    digitcount = floor(log(l, 10))
    log10pwr = log(pwr, 10)
    raised, found = -1, 0
    while found < n:
        raised += 1
        firstdigits = floor(10**(modf(log10pwr * raised)[0] + digitcount))
        if firstdigits == l:
            found += 1
    return raised


if __name__ == '__main__':
    for l, n in [(12, 1), (12, 2), (123, 45), (123, 12345), (123, 678910)]:
        print(f"p({l}, {n}) =", p(l, n))
Task: First power of 2 that has leading decimal digits of 12
Java: public class FirstPowerOfTwo {

    public static void main(String[] args) {
        runTest(12, 1);
        runTest(12, 2);
        runTest(123, 45);
        runTest(123, 12345);
        runTest(123, 678910);
    }
    
    private static void runTest(int l, int n) {
        System.out.printf("p(%d, %d) = %,d%n", l, n, p(l, n));
    }
    
    public static int p(int l, int n) {
        int test = 0;
        double log = Math.log(2) / Math.log(10);
        int factor = 1;
        int loop = l;
        while ( loop > 10 ) {
            factor *= 10;
            loop /= 10;
        }
        while ( n > 0) {
            test++;
            int val = (int) (factor * Math.pow(10, test * log % 1));
            if ( val == l ) {
                n--;
            }
        }
        return test;
    }
    
}

VB: Module Module1

    Function Func(ByVal l As Integer, ByVal n As Integer) As Long
        Dim res As Long = 0, f As Long = 1
        Dim lf As Double = Math.Log10(2)
        Dim i As Integer = l

        While i > 10
            f *= 10
            i /= 10
        End While

        While n > 0
            res += 1

            If CInt((f * Math.Pow(10, res * lf Mod 1))) = l Then
                n -= 1
            End If
        End While

        Return res
    End Function

    Sub Main()
        Dim values = {Tuple.Create(12, 1), Tuple.Create(12, 2), Tuple.Create(123, 45), Tuple.Create(123, 12345), Tuple.Create(123, 678910), Tuple.Create(99, 1)}
        For Each pair In values
            Console.WriteLine("p({0,3}, {1,6}) = {2,11:n0}", pair.Item1, pair.Item2, Func(pair.Item1, pair.Item2))
        Next
    End Sub

End Module
Task: First power of 2 that has leading decimal digits of 12
Go: package main

import (
    "fmt"
    "math"
    "time"
)

const ld10 = math.Ln2 / math.Ln10

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func p(L, n uint64) uint64 {
    i := L
    digits := uint64(1)
    for i >= 10 {
        digits *= 10
        i /= 10
    }
    count := uint64(0)
    for i = 0; count < n; i++ {
        e := math.Exp(math.Ln10 * math.Mod(float64(i)*ld10, 1))
        if uint64(math.Trunc(e*float64(digits))) == L {
            count++            
        }
    }
    return i - 1
}

func main() {
    start := time.Now()
    params := [][2]uint64{{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}}
    for _, param := range params {
        fmt.Printf("p(%d, %d) = %s\n", param[0], param[1], commatize(p(param[0], param[1])))
    }
    fmt.Printf("\nTook %s\n", time.Since(start))
}

Python: from math import log, modf, floor

def p(l, n, pwr=2):
    l = int(abs(l))
    digitcount = floor(log(l, 10))
    log10pwr = log(pwr, 10)
    raised, found = -1, 0
    while found < n:
        raised += 1
        firstdigits = floor(10**(modf(log10pwr * raised)[0] + digitcount))
        if firstdigits == l:
            found += 1
    return raised


if __name__ == '__main__':
    for l, n in [(12, 1), (12, 2), (123, 45), (123, 12345), (123, 678910)]:
        print(f"p({l}, {n}) =", p(l, n))
Task: First power of 2 that has leading decimal digits of 12
Python: from math import log, modf, floor

def p(l, n, pwr=2):
    l = int(abs(l))
    digitcount = floor(log(l, 10))
    log10pwr = log(pwr, 10)
    raised, found = -1, 0
    while found < n:
        raised += 1
        firstdigits = floor(10**(modf(log10pwr * raised)[0] + digitcount))
        if firstdigits == l:
            found += 1
    return raised


if __name__ == '__main__':
    for l, n in [(12, 1), (12, 2), (123, 45), (123, 12345), (123, 678910)]:
        print(f"p({l}, {n}) =", p(l, n))

VB: Module Module1

    Function Func(ByVal l As Integer, ByVal n As Integer) As Long
        Dim res As Long = 0, f As Long = 1
        Dim lf As Double = Math.Log10(2)
        Dim i As Integer = l

        While i > 10
            f *= 10
            i /= 10
        End While

        While n > 0
            res += 1

            If CInt((f * Math.Pow(10, res * lf Mod 1))) = l Then
                n -= 1
            End If
        End While

        Return res
    End Function

    Sub Main()
        Dim values = {Tuple.Create(12, 1), Tuple.Create(12, 2), Tuple.Create(123, 45), Tuple.Create(123, 12345), Tuple.Create(123, 678910), Tuple.Create(99, 1)}
        For Each pair In values
            Console.WriteLine("p({0,3}, {1,6}) = {2,11:n0}", pair.Item1, pair.Item2, Func(pair.Item1, pair.Item2))
        Next
    End Sub

End Module
Task: First power of 2 that has leading decimal digits of 12
C: #include <math.h>
#include <stdio.h>

int p(int l, int n) {
    int test = 0;
    double logv = log(2.0) / log(10.0);
    int factor = 1;
    int loop = l;
    while (loop > 10) {
        factor *= 10;
        loop /= 10;
    }
    while (n > 0) {
        int val;

        test++;
        val = (int)(factor * pow(10.0, fmod(test * logv, 1)));
        if (val == l) {
            n--;
        }
    }
    return test;
}

void runTest(int l, int n) {
    printf("p(%d, %d) = %d\n", l, n, p(l, n));
}

int main() {
    runTest(12, 1);
    runTest(12, 2);
    runTest(123, 45);
    runTest(123, 12345);
    runTest(123, 678910);

    return 0;
}

VB: Module Module1

    Function Func(ByVal l As Integer, ByVal n As Integer) As Long
        Dim res As Long = 0, f As Long = 1
        Dim lf As Double = Math.Log10(2)
        Dim i As Integer = l

        While i > 10
            f *= 10
            i /= 10
        End While

        While n > 0
            res += 1

            If CInt((f * Math.Pow(10, res * lf Mod 1))) = l Then
                n -= 1
            End If
        End While

        Return res
    End Function

    Sub Main()
        Dim values = {Tuple.Create(12, 1), Tuple.Create(12, 2), Tuple.Create(123, 45), Tuple.Create(123, 12345), Tuple.Create(123, 678910), Tuple.Create(99, 1)}
        For Each pair In values
            Console.WriteLine("p({0,3}, {1,6}) = {2,11:n0}", pair.Item1, pair.Item2, Func(pair.Item1, pair.Item2))
        Next
    End Sub

End Module
Task: First power of 2 that has leading decimal digits of 12
Go: package main

import (
    "fmt"
    "math"
    "time"
)

const ld10 = math.Ln2 / math.Ln10

func commatize(n uint64) string {
    s := fmt.Sprintf("%d", n)
    le := len(s)
    for i := le - 3; i >= 1; i -= 3 {
        s = s[0:i] + "," + s[i:]
    }
    return s
}

func p(L, n uint64) uint64 {
    i := L
    digits := uint64(1)
    for i >= 10 {
        digits *= 10
        i /= 10
    }
    count := uint64(0)
    for i = 0; count < n; i++ {
        e := math.Exp(math.Ln10 * math.Mod(float64(i)*ld10, 1))
        if uint64(math.Trunc(e*float64(digits))) == L {
            count++            
        }
    }
    return i - 1
}

func main() {
    start := time.Now()
    params := [][2]uint64{{12, 1}, {12, 2}, {123, 45}, {123, 12345}, {123, 678910}}
    for _, param := range params {
        fmt.Printf("p(%d, %d) = %s\n", param[0], param[1], commatize(p(param[0], param[1])))
    }
    fmt.Printf("\nTook %s\n", time.Since(start))
}

VB: Module Module1

    Function Func(ByVal l As Integer, ByVal n As Integer) As Long
        Dim res As Long = 0, f As Long = 1
        Dim lf As Double = Math.Log10(2)
        Dim i As Integer = l

        While i > 10
            f *= 10
            i /= 10
        End While

        While n > 0
            res += 1

            If CInt((f * Math.Pow(10, res * lf Mod 1))) = l Then
                n -= 1
            End If
        End While

        Return res
    End Function

    Sub Main()
        Dim values = {Tuple.Create(12, 1), Tuple.Create(12, 2), Tuple.Create(123, 45), Tuple.Create(123, 12345), Tuple.Create(123, 678910), Tuple.Create(99, 1)}
        For Each pair In values
            Console.WriteLine("p({0,3}, {1,6}) = {2,11:n0}", pair.Item1, pair.Item2, Func(pair.Item1, pair.Item2))
        Next
    End Sub

End Module
Task: Null object
C: #include <stdio.h>

int main()
{
	char *object = 0;

	if (object == NULL) {
		puts("object is null");
	}
	return 0;
}

C++: #include <iostream>
#include <cstdlib>
if (object == 0) {
   std::cout << "object is null";
}
Task: Null object
C: #include <stdio.h>

int main()
{
	char *object = 0;

	if (object == NULL) {
		puts("object is null");
	}
	return 0;
}

Go: package main

import "fmt"

var (
    s []int       
    p *int        
    f func()      
    i interface{} 
    m map[int]int 
    c chan int    
)

func main() {
    fmt.Println(s == nil)
    fmt.Println(p == nil)
    fmt.Println(f == nil)
    fmt.Println(i == nil)
    fmt.Println(m == nil)
    fmt.Println(c == nil)
}
Task: Null object
C: #include <stdio.h>

int main()
{
	char *object = 0;

	if (object == NULL) {
		puts("object is null");
	}
	return 0;
}

Java: module NullObject
    {
    void run()
        {
        @Inject Console console;
        console.print($"Null value={Null}, Null.toString()={Null.toString()}");

     
        String? s = Null;       
        String s2 = "test";
        console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");

     
        Int len = s?.size : 0;
        console.print($"len={len}");

        if (String test ?= s)
            {
            
            }
        else
            {
            s = "a non-null value";
            }

     
        s2 = s;                 
        console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
        }
    }
Task: Null object
C: #include <stdio.h>

int main()
{
	char *object = 0;

	if (object == NULL) {
		puts("object is null");
	}
	return 0;
}

Python: x = None
if x is None:
  print "x is None"
else:
  print "x is not None"
Task: Null object
C: #include <stdio.h>

int main()
{
	char *object = 0;

	if (object == NULL) {
		puts("object is null");
	}
	return 0;
}

VB: Public Sub Main()
    Dim c As VBA.Collection
     
    
    Debug.Print c Is Nothing
     
    
    Set c = New VBA.Collection
    Debug.Print Not c Is Nothing
     
    
    Set c = Nothing
    Debug.Print c Is Nothing
End Sub
Task: Null object
C#: if (foo == null)
    Console.WriteLine("foo is null");

C++: #include <iostream>
#include <cstdlib>
if (object == 0) {
   std::cout << "object is null";
}
Task: Null object
C++: #include <iostream>
#include <cstdlib>
if (object == 0) {
   std::cout << "object is null";
}

Go: package main

import "fmt"

var (
    s []int       
    p *int        
    f func()      
    i interface{} 
    m map[int]int 
    c chan int    
)

func main() {
    fmt.Println(s == nil)
    fmt.Println(p == nil)
    fmt.Println(f == nil)
    fmt.Println(i == nil)
    fmt.Println(m == nil)
    fmt.Println(c == nil)
}
Task: Null object
C++: #include <iostream>
#include <cstdlib>
if (object == 0) {
   std::cout << "object is null";
}

Java: module NullObject
    {
    void run()
        {
        @Inject Console console;
        console.print($"Null value={Null}, Null.toString()={Null.toString()}");

     
        String? s = Null;       
        String s2 = "test";
        console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");

     
        Int len = s?.size : 0;
        console.print($"len={len}");

        if (String test ?= s)
            {
            
            }
        else
            {
            s = "a non-null value";
            }

     
        s2 = s;                 
        console.print($"s={s}, s2={s2}, (s==s2)={s==s2}");
        }
    }
Task: Null object
C++: #include <iostream>
#include <cstdlib>
if (object == 0) {
   std::cout << "object is null";
}

Python: x = None
if x is None:
  print "x is None"
else:
  print "x is not None"
Task: Null object
C#: if (foo == null)
    Console.WriteLine("foo is null");

Go: package main

import "fmt"

var (
    s []int       
    p *int        
    f func()      
    i interface{} 
    m map[int]int 
    c chan int    
)

func main() {
    fmt.Println(s == nil)
    fmt.Println(p == nil)
    fmt.Println(f == nil)
    fmt.Println(i == nil)
    fmt.Println(m == nil)
    fmt.Println(c == nil)
}
Task: Null object
C#: if (foo == null)
    Console.WriteLine("foo is null");

Python: x = None
if x is None:
  print "x is None"
else:
  print "x is not None"
Task: Null object
C#: if (foo == null)
    Console.WriteLine("foo is null");

VB: Public Sub Main()
    Dim c As VBA.Collection
     
    
    Debug.Print c Is Nothing
     
    
    Set c = New VBA.Collection
    Debug.Print Not c Is Nothing
     
    
    Set c = Nothing
    Debug.Print c Is Nothing
End Sub