WeixiangYan/CodeTransOcean huggingface dataset:
Task: The Name Game




Go: package main

import (
    "fmt"
    "strings"
)

func printVerse(name string) {
    x := strings.Title(strings.ToLower(name))
    y := x[1:]
    if strings.Contains("AEIOU", x[:1]) {
        y = strings.ToLower(x)
    }
    b := "b" + y
    f := "f" + y
    m := "m" + y
    switch x[0] {
    case 'B':
        b = y
    case 'F':
        f = y
    case 'M':
        m = y
    }
    fmt.Printf("%s, %s, bo-%s\n", x, x, b)
    fmt.Printf("Banana-fana fo-%s\n", f)
    fmt.Printf("Fee-fi-mo-%s\n", m)
    fmt.Printf("%s!\n\n", x)
}

func main() {
    names := [6]string{"gARY", "Earl", "Billy", "Felix", "Mary", "SHIRley"}
    for _, name := range names {
        printVerse(name)
    }
}








Ada: with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

procedure The_Name_Game
is
   package ACH renames Ada.Characters.Handling;
   package ASU renames Ada.Strings.Unbounded;
   function "+"(input : in String) return ASU.Unbounded_String renames ASU.To_Unbounded_String;
   function "+"(input : in ASU.Unbounded_String) return String renames ASU.To_String;
   
   function Normalize_Case(input : in String) return String is
   begin
      return ACH.To_Upper(input(input'First))
        & ACH.To_Lower(input(input'First + 1 .. input'Last));
   end Normalize_Case;

   function Transform(input : in String; letter : in Character) return String is
   begin
      case input(input'First) is
         when 'A' | 'E' | 'I' | 'O' | 'U' =>
            return letter & ACH.To_Lower(input);
         when others =>
            if ACH.To_Lower(input(input'First)) = letter then
               return input(input'First + 1 .. input'Last);
            else
               return letter & input(input'First + 1 .. input'Last);
            end if;
      end case;
   end Transform;
   
   procedure Lyrics(name : in String)
   is
      normalized : constant String := Normalize_Case(name);
   begin
      Ada.Text_IO.Put_Line(normalized & ", " & normalized & ", bo-" & Transform(normalized, 'b'));
      Ada.Text_IO.Put_Line("Banana-fana, fo-" & Transform(normalized, 'f'));
      Ada.Text_IO.Put_Line("fi-fee-mo-" & Transform(normalized, 'm'));
      Ada.Text_IO.Put_Line(normalized & '!');
      Ada.Text_IO.New_Line;
   end Lyrics;

   names : constant array(1 .. 5) of ASU.Unbounded_String :=
     (+"Gary",
      +"EARL",
      +"billy",
      +"FeLiX",
      +"Mary");
begin
   for name of names loop
      Lyrics(+name);
   end loop;
end The_Name_Game;
Task: The Name Game





Java: import java.util.stream.Stream;

public class NameGame {
    private static void printVerse(String name) {
        StringBuilder sb = new StringBuilder(name.toLowerCase());
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        String x = sb.toString();
        String y = "AEIOU".indexOf(x.charAt(0)) > -1 ? x.toLowerCase() : x.substring(1);
        String b = "b" + y;
        String f = "f" + y;
        String m = "m" + y;
        switch (x.charAt(0)) {
            case 'B':
                b = y;
                break;
            case 'F':
                f = y;
                break;
            case 'M':
                m = y;
                break;
            default:
                
                break;
        }
        System.out.printf("%s, %s, bo-%s\n", x, x, b);
        System.out.printf("Banana-fana fo-%s\n", f);
        System.out.printf("Fee-fi-mo-%s\n", m);
        System.out.printf("%s!\n\n", x);
    }

    public static void main(String[] args) {
        Stream.of("Gary", "Earl", "Billy", "Felix", "Mary", "Steve").forEach(NameGame::printVerse);
    }
}







Ada: with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

procedure The_Name_Game
is
   package ACH renames Ada.Characters.Handling;
   package ASU renames Ada.Strings.Unbounded;
   function "+"(input : in String) return ASU.Unbounded_String renames ASU.To_Unbounded_String;
   function "+"(input : in ASU.Unbounded_String) return String renames ASU.To_String;
   
   function Normalize_Case(input : in String) return String is
   begin
      return ACH.To_Upper(input(input'First))
        & ACH.To_Lower(input(input'First + 1 .. input'Last));
   end Normalize_Case;

   function Transform(input : in String; letter : in Character) return String is
   begin
      case input(input'First) is
         when 'A' | 'E' | 'I' | 'O' | 'U' =>
            return letter & ACH.To_Lower(input);
         when others =>
            if ACH.To_Lower(input(input'First)) = letter then
               return input(input'First + 1 .. input'Last);
            else
               return letter & input(input'First + 1 .. input'Last);
            end if;
      end case;
   end Transform;
   
   procedure Lyrics(name : in String)
   is
      normalized : constant String := Normalize_Case(name);
   begin
      Ada.Text_IO.Put_Line(normalized & ", " & normalized & ", bo-" & Transform(normalized, 'b'));
      Ada.Text_IO.Put_Line("Banana-fana, fo-" & Transform(normalized, 'f'));
      Ada.Text_IO.Put_Line("fi-fee-mo-" & Transform(normalized, 'm'));
      Ada.Text_IO.Put_Line(normalized & '!');
      Ada.Text_IO.New_Line;
   end Lyrics;

   names : constant array(1 .. 5) of ASU.Unbounded_String :=
     (+"Gary",
      +"EARL",
      +"billy",
      +"FeLiX",
      +"Mary");
begin
   for name of names loop
      Lyrics(+name);
   end loop;
end The_Name_Game;
Task: The Name Game







Python: def print_verse(n):
    l = ['b', 'f', 'm']
    s = n[1:]
    if str.lower(n[0]) in l:
        l[l.index(str.lower(n[0]))] = ''
    elif n[0] in ['A', 'E', 'I', 'O', 'U']:
        s = str.lower(n)
    print('{0}, {0}, bo-{2}{1}\nBanana-fana fo-{3}{1}\nFee-fi-mo-{4}{1}\n{0}!\n'.format(n, s, *l))


for n in ['Gary', 'Earl', 'Billy', 'Felix', 'Mary']:
    print_verse(n)





Ada: with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

procedure The_Name_Game
is
   package ACH renames Ada.Characters.Handling;
   package ASU renames Ada.Strings.Unbounded;
   function "+"(input : in String) return ASU.Unbounded_String renames ASU.To_Unbounded_String;
   function "+"(input : in ASU.Unbounded_String) return String renames ASU.To_String;
   
   function Normalize_Case(input : in String) return String is
   begin
      return ACH.To_Upper(input(input'First))
        & ACH.To_Lower(input(input'First + 1 .. input'Last));
   end Normalize_Case;

   function Transform(input : in String; letter : in Character) return String is
   begin
      case input(input'First) is
         when 'A' | 'E' | 'I' | 'O' | 'U' =>
            return letter & ACH.To_Lower(input);
         when others =>
            if ACH.To_Lower(input(input'First)) = letter then
               return input(input'First + 1 .. input'Last);
            else
               return letter & input(input'First + 1 .. input'Last);
            end if;
      end case;
   end Transform;
   
   procedure Lyrics(name : in String)
   is
      normalized : constant String := Normalize_Case(name);
   begin
      Ada.Text_IO.Put_Line(normalized & ", " & normalized & ", bo-" & Transform(normalized, 'b'));
      Ada.Text_IO.Put_Line("Banana-fana, fo-" & Transform(normalized, 'f'));
      Ada.Text_IO.Put_Line("fi-fee-mo-" & Transform(normalized, 'm'));
      Ada.Text_IO.Put_Line(normalized & '!');
      Ada.Text_IO.New_Line;
   end Lyrics;

   names : constant array(1 .. 5) of ASU.Unbounded_String :=
     (+"Gary",
      +"EARL",
      +"billy",
      +"FeLiX",
      +"Mary");
begin
   for name of names loop
      Lyrics(+name);
   end loop;
end The_Name_Game;
Task: The Name Game








VB: Option Explicit

Sub Main()
Dim a, r, i As Integer
Const SCHEM As String = "(X), (X), bo-b(Y)^Banana-fana fo-f(Y)^Fee-fi-mo-m(Y)^(X)!^"
   
   a = Array("GaRY", "Earl", "Billy", "Felix", "Mary", "Mike", "Frank")
   
   r = TheGameName(a, SCHEM)
   
   For i = LBound(r) To UBound(r)
      Debug.Print r(i)
   Next i
End Sub

Private Function TheGameName(MyArr, S As String) As String()
Dim i As Integer, s1 As String, s2 As String, tp As String, t() As String
   ReDim t(UBound(MyArr))
   For i = LBound(MyArr) To UBound(MyArr)
      tp = Replace(S, "^", vbCrLf)
      s2 = LCase(Mid(MyArr(i), 2)): s1 = UCase(Left(MyArr(i), 1)) & s2
      Select Case UCase(Left(MyArr(i), 1))
         Case "A", "E", "I", "O", "U": tp = Replace(tp, "(Y)", LCase(MyArr(i)))
         Case "B", "F", "M"
            tp = Replace(tp, "(Y)", s2)
            tp = Replace(tp, LCase(MyArr(i)), s2)
         Case Else: tp = Replace(tp, "(Y)", s2)
      End Select
      t(i) = Replace(tp, "(X)", s1)
   Next
   TheGameName = t
End Function




Ada: with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with Ada.Text_IO;

procedure The_Name_Game
is
   package ACH renames Ada.Characters.Handling;
   package ASU renames Ada.Strings.Unbounded;
   function "+"(input : in String) return ASU.Unbounded_String renames ASU.To_Unbounded_String;
   function "+"(input : in ASU.Unbounded_String) return String renames ASU.To_String;
   
   function Normalize_Case(input : in String) return String is
   begin
      return ACH.To_Upper(input(input'First))
        & ACH.To_Lower(input(input'First + 1 .. input'Last));
   end Normalize_Case;

   function Transform(input : in String; letter : in Character) return String is
   begin
      case input(input'First) is
         when 'A' | 'E' | 'I' | 'O' | 'U' =>
            return letter & ACH.To_Lower(input);
         when others =>
            if ACH.To_Lower(input(input'First)) = letter then
               return input(input'First + 1 .. input'Last);
            else
               return letter & input(input'First + 1 .. input'Last);
            end if;
      end case;
   end Transform;
   
   procedure Lyrics(name : in String)
   is
      normalized : constant String := Normalize_Case(name);
   begin
      Ada.Text_IO.Put_Line(normalized & ", " & normalized & ", bo-" & Transform(normalized, 'b'));
      Ada.Text_IO.Put_Line("Banana-fana, fo-" & Transform(normalized, 'f'));
      Ada.Text_IO.Put_Line("fi-fee-mo-" & Transform(normalized, 'm'));
      Ada.Text_IO.Put_Line(normalized & '!');
      Ada.Text_IO.New_Line;
   end Lyrics;

   names : constant array(1 .. 5) of ASU.Unbounded_String :=
     (+"Gary",
      +"EARL",
      +"billy",
      +"FeLiX",
      +"Mary");
begin
   for name of names loop
      Lyrics(+name);
   end loop;
end The_Name_Game;
Task: The Name Game

C: #include <stdio.h>
#include <string.h>

void print_verse(const char *name) {
    char *x, *y; 
    int b = 1, f = 1, m = 1, i = 1;

    
    x = strdup(name);     
    x[0] = toupper(x[0]);
    for (; x[i]; ++i) x[i] = tolower(x[i]);
   
    if (strchr("AEIOU", x[0])) {
        y = strdup(x);
        y[0] = tolower(y[0]); 
    }
    else {
        y = x + 1;
    }

    switch(x[0]) {
        case 'B': b = 0; break;
        case 'F': f = 0; break;
        case 'M': m = 0; break;
        default : break;
    }
      
    printf("%s, %s, bo-%s%s\n", x, x, (b) ? "b" : "", y);
    printf("Banana-fana fo-%s%s\n", (f) ? "f" : "", y);
    printf("Fee-fi-mo-%s%s\n", (m) ? "m" : "", y);
    printf("%s!\n\n", x);
}

int main() {
    int i;
    const char *names[6] = {"gARY", "Earl", "Billy", "Felix", "Mary", "sHIRley"};
    for (i = 0; i < 6; ++i) print_verse(names[i]);
    return 0;
}
Task: The Name Game



C#: using System;
using System.Collections.Generic;
using System.Text;

namespace TheNameGame {
    class Program {
        static void PrintVerse(string name) {
            StringBuilder sb = new StringBuilder(name.ToLower());
            sb[0] = Char.ToUpper(sb[0]);
            string x = sb.ToString();
            string y = "AEIOU".IndexOf(x[0]) > -1 ? x.ToLower() : x.Substring(1);
            string b = "b" + y;
            string f = "f" + y;
            string m = "m" + y;
            switch (x[0]) {
                case 'B':
                    b = y;
                    break;
                case 'F':
                    f = y;
                    break;
                case 'M':
                    m = y;
                    break;
            }
            Console.WriteLine("{0}, {0}, bo-{1}", x, b);
            Console.WriteLine("Banana-fana fo-{0}", f);
            Console.WriteLine("Fee-fi-mo-{0}", m);
            Console.WriteLine("{0}!", x);
            Console.WriteLine();
        }

        static void Main(string[] args) {
            List<string> nameList = new List<string>() { "Gary", "Earl", "Billy", "Felix", "Mary", "Steve" };
            nameList.ForEach(PrintVerse);
        }
    }
}
Task: The Name Game


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

static void printVerse(const std::string& name) {
    std::string x = name;
    std::transform(x.begin(), x.end(), x.begin(), ::tolower);
    x[0] = toupper(x[0]);

    std::string y;
    switch (x[0]) {
    case 'A':
    case 'E':
    case 'I':
    case 'O':
    case 'U':
        y = x;
        std::transform(y.begin(), y.end(), y.begin(), ::tolower);
        break;
    default:
        y = x.substr(1);
        break;
    }

    std::string b("b" + y);
    std::string f("f" + y);
    std::string m("m" + y);

    switch (x[0]) {
    case 'B':
        b = y;
        break;
    case 'F':
        f = y;
        break;
    case 'M':
        m = y;
        break;
    default:
        break;
    }

    printf("%s, %s, bo-%s\n", x.c_str(), x.c_str(), b.c_str());
    printf("Banana-fana fo-%s\n", f.c_str());
    printf("Fee-fi-mo-%s\n", m.c_str());
    printf("%s!\n\n", x.c_str());
}

int main() {
    using namespace std;

    vector<string> nameList{ "Gary", "Earl", "Billy", "Felix", "Mary", "Steve" };
    for (auto& name : nameList) {
        printVerse(name);
    }

    return 0;
}
Task: The Name Game





Java: import java.util.stream.Stream;

public class NameGame {
    private static void printVerse(String name) {
        StringBuilder sb = new StringBuilder(name.toLowerCase());
        sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
        String x = sb.toString();
        String y = "AEIOU".indexOf(x.charAt(0)) > -1 ? x.toLowerCase() : x.substring(1);
        String b = "b" + y;
        String f = "f" + y;
        String m = "m" + y;
        switch (x.charAt(0)) {
            case 'B':
                b = y;
                break;
            case 'F':
                f = y;
                break;
            case 'M':
                m = y;
                break;
            default:
                
                break;
        }
        System.out.printf("%s, %s, bo-%s\n", x, x, b);
        System.out.printf("Banana-fana fo-%s\n", f);
        System.out.printf("Fee-fi-mo-%s\n", m);
        System.out.printf("%s!\n\n", x);
    }

    public static void main(String[] args) {
        Stream.of("Gary", "Earl", "Billy", "Felix", "Mary", "Steve").forEach(NameGame::printVerse);
    }
}
Task: The Name Game







Python: def print_verse(n):
    l = ['b', 'f', 'm']
    s = n[1:]
    if str.lower(n[0]) in l:
        l[l.index(str.lower(n[0]))] = ''
    elif n[0] in ['A', 'E', 'I', 'O', 'U']:
        s = str.lower(n)
    print('{0}, {0}, bo-{2}{1}\nBanana-fana fo-{3}{1}\nFee-fi-mo-{4}{1}\n{0}!\n'.format(n, s, *l))


for n in ['Gary', 'Earl', 'Billy', 'Felix', 'Mary']:
    print_verse(n)
Task: The Name Game








VB: Option Explicit

Sub Main()
Dim a, r, i As Integer
Const SCHEM As String = "(X), (X), bo-b(Y)^Banana-fana fo-f(Y)^Fee-fi-mo-m(Y)^(X)!^"
   
   a = Array("GaRY", "Earl", "Billy", "Felix", "Mary", "Mike", "Frank")
   
   r = TheGameName(a, SCHEM)
   
   For i = LBound(r) To UBound(r)
      Debug.Print r(i)
   Next i
End Sub

Private Function TheGameName(MyArr, S As String) As String()
Dim i As Integer, s1 As String, s2 As String, tp As String, t() As String
   ReDim t(UBound(MyArr))
   For i = LBound(MyArr) To UBound(MyArr)
      tp = Replace(S, "^", vbCrLf)
      s2 = LCase(Mid(MyArr(i), 2)): s1 = UCase(Left(MyArr(i), 1)) & s2
      Select Case UCase(Left(MyArr(i), 1))
         Case "A", "E", "I", "O", "U": tp = Replace(tp, "(Y)", LCase(MyArr(i)))
         Case "B", "F", "M"
            tp = Replace(tp, "(Y)", s2)
            tp = Replace(tp, LCase(MyArr(i)), s2)
         Case Else: tp = Replace(tp, "(Y)", s2)
      End Select
      t(i) = Replace(tp, "(X)", s1)
   Next
   TheGameName = t
End Function
Task: The Name Game




Go: package main

import (
    "fmt"
    "strings"
)

func printVerse(name string) {
    x := strings.Title(strings.ToLower(name))
    y := x[1:]
    if strings.Contains("AEIOU", x[:1]) {
        y = strings.ToLower(x)
    }
    b := "b" + y
    f := "f" + y
    m := "m" + y
    switch x[0] {
    case 'B':
        b = y
    case 'F':
        f = y
    case 'M':
        m = y
    }
    fmt.Printf("%s, %s, bo-%s\n", x, x, b)
    fmt.Printf("Banana-fana fo-%s\n", f)
    fmt.Printf("Fee-fi-mo-%s\n", m)
    fmt.Printf("%s!\n\n", x)
}

func main() {
    names := [6]string{"gARY", "Earl", "Billy", "Felix", "Mary", "SHIRley"}
    for _, name := range names {
        printVerse(name)
    }
}
Task: DNS query



C#:         private string LookupDns(string s)
        {
            try
            {
                System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry(s);

                string result = ip.AddressList[0].ToString();

                for (int i = 1; i < ip.AddressList.Length; ++i)
                    result += ", " + ip.AddressList[i].ToString();

                return result;
            }
            catch (System.Net.Sockets.SocketException se)
            {
                return se.Message;
            }
        }









Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query

C: #include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>		
#include <stdio.h>		
#include <stdlib.h>		
#include <string.h>		

int
main()
{
	struct addrinfo hints, *res, *res0;
	int error;
	char host[NI_MAXHOST];

	
	memset(&hints, 0, sizeof hints);
	hints.ai_family = PF_UNSPEC;     
	hints.ai_socktype = SOCK_DGRAM;  

	
	error = getaddrinfo("www.kame.net", NULL, &hints, &res0);
	if (error) {
		fprintf(stderr, "%s\n", gai_strerror(error));
		exit(1);
	}

	
	for (res = res0; res; res = res->ai_next) {
		
		error = getnameinfo(res->ai_addr, res->ai_addrlen,
		    host, sizeof host, NULL, 0, NI_NUMERICHOST);

		if (error) {
			fprintf(stderr, "%s\n", gai_strerror(error));
		} else {
			
			printf("%s\n", host);
		}
	}

	
	freeaddrinfo(res0);

	return 0;
}











Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query


C++: #include <Rcpp.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace Rcpp ;


CharacterVector getNameInfo(std::string fqdn) {

  struct addrinfo hints, *res, *res0;
	int error;
	char host[NI_MAXHOST];

  memset(&hints, 0, sizeof hints);
	hints.ai_family = PF_UNSPEC;
	hints.ai_socktype = SOCK_DGRAM;

	error = getaddrinfo(fqdn.c_str(), NULL, &hints, &res0);
	if (error) { return(NA_STRING);	}

  int i = 0 ;
	for (res = res0; res; res = res->ai_next) {
  	error = getnameinfo(res->ai_addr, res->ai_addrlen,
		    host, sizeof host, NULL, 0, NI_NUMERICHOST);
		if (!error) { i++ ; }
	}

  CharacterVector results(i) ;

  i = 0;

  for (res = res0; res; res = res->ai_next) {
		error = getnameinfo(res->ai_addr, res->ai_addrlen,
		    host, sizeof host, NULL, 0, NI_NUMERICHOST);
		if (!error) { results[i++] = host ; }
	}

  freeaddrinfo(res0);

  return(results) ;

}










Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query




Go: package main

import (
    "fmt"
    "net"
)

func main() {
    if addrs, err := net.LookupHost("www.kame.net"); err == nil {
        fmt.Println(addrs)
    } else {
        fmt.Println(err)
    }
}








Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query





Java: import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.UnknownHostException;

class DnsQuery {
    public static void main(String[] args) {
        try {
            InetAddress[] ipAddr = InetAddress.getAllByName("www.kame.net");
            for(int i=0; i < ipAddr.length ; i++) {
                if (ipAddr[i] instanceof Inet4Address) {
                    System.out.println("IPv4 : " + ipAddr[i].getHostAddress());
                } else if (ipAddr[i] instanceof Inet6Address) {
                    System.out.println("IPv6 : " + ipAddr[i].getHostAddress());
                }
            }
        } catch (UnknownHostException uhe) {
            System.err.println("unknown host");
        }
    }
}







Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query







Python: >>> import socket
>>> ips = set(i[4][0] for i in socket.getaddrinfo('www.kame.net', 80))
>>> for ip in ips: print ip
...
2001:200:dff:fff1:216:3eff:feb1:44d7
203.178.141.194





Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;
Task: DNS query








VB: Function dns_query(url,ver)
	Set r = New RegExp
	r.Pattern = "Pinging.+?\[(.+?)\].+"
	Set objshell = CreateObject("WScript.Shell")
	Set objexec = objshell.Exec("%comspec% /c " & "ping -" & ver & " " & url)
	WScript.StdOut.WriteLine "URL: " & url
	Do Until objexec.StdOut.AtEndOfStream
		line = objexec.StdOut.ReadLine
		If r.Test(line) Then
			WScript.StdOut.WriteLine "IP Version " &_
				ver & ": " & r.Replace(line,"$1")
		End If
	Loop
End Function

Call dns_query(WScript.Arguments(0),WScript.Arguments(1))




Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure DNSQuerying is

   Host         : Host_Entry_Type (1, 1);
   Inet_Addr_V4 : Inet_Addr_Type (Family_Inet);
begin

   Host         := Get_Host_By_Name (Name => "www.kame.net");
   Inet_Addr_V4 := Addresses (Host);
   Put ("IPv4: " & Image (Value => Inet_Addr_V4));
end DNSQuerying;