WeixiangYan/CodeTransOcean huggingface dataset:
Task: Program name





Java: public class ScriptName {
	public static void main(String[] args) {
		String program = System.getProperty("sun.java.command").split(" ")[0];
		System.out.println("Program: " + program);
	}
}







Ada: with Ada.Command_Line, Ada.Text_IO;

procedure Command_Name is
begin
   Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name);
end Command_Name;
Task: Program name







Python: 

import sys

def main():
    program = sys.argv[0]
    print("Program: %s" % program)

if __name__ == "__main__":
    main()





Ada: with Ada.Command_Line, Ada.Text_IO;

procedure Command_Name is
begin
   Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name);
end Command_Name;
Task: Program name








VB: Debug.Print Application.Name




Ada: with Ada.Command_Line, Ada.Text_IO;

procedure Command_Name is
begin
   Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name);
end Command_Name;
Task: Program name

C: #include <stdio.h>

int main(int argc, char **argv) {
	printf("Executable: %s\n", argv[0]);

	return 0;
}
Task: Program name



C#: using System;
namespace ProgramName
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.Write(Environment.CommandLine);
		}
	}
}
Task: Program name


C++: #include <iostream>

using namespace std;

int main(int argc, char **argv) {
	char *program = argv[0];
	cout << "Program: " << program << endl;
}
Task: Program name





Java: public class ScriptName {
	public static void main(String[] args) {
		String program = System.getProperty("sun.java.command").split(" ")[0];
		System.out.println("Program: " + program);
	}
}
Task: Program name







Python: 

import sys

def main():
    program = sys.argv[0]
    print("Program: %s" % program)

if __name__ == "__main__":
    main()
Task: Program name




Go: package main

import (
    "fmt"
    "os"
)

func main() {
    fmt.Println("Program:", os.Args[0])
}
Task: Program name








VB: Debug.Print Application.Name
Task: Program name



C#: using System;
namespace ProgramName
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.Write(Environment.CommandLine);
		}
	}
}








Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name


C++: #include <iostream>

using namespace std;

int main(int argc, char **argv) {
	char *program = argv[0];
	cout << "Program: " << program << endl;
}









Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name

C: #include <stdio.h>

int main(int argc, char **argv) {
	printf("Executable: %s\n", argv[0]);

	return 0;
}










Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name





Java: public class ScriptName {
	public static void main(String[] args) {
		String program = System.getProperty("sun.java.command").split(" ")[0];
		System.out.println("Program: " + program);
	}
}






Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name







Python: 

import sys

def main():
    program = sys.argv[0]
    print("Program: %s" % program)

if __name__ == "__main__":
    main()




Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name








VB: Debug.Print Application.Name



Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name






PHP: <?php
$program = $_SERVER["SCRIPT_NAME"];
echo "Program: $program\n";
?>





Fortran: 























module sundry

contains

  subroutine verify_name(required)
    
    character(len=*), intent(in) :: required
    character(len=1024) :: name
    integer :: length, status
    
    call get_command_argument(0, name, length, status)
    if (0 /= status) stop
    if ((len_trim(name)+1) .ne. (index(name, required, back=.true.) + len(required))) stop
    write(6,*) trim(name)//' approved.'
  end subroutine verify_name

end module sundry

program name
  use sundry
  call verify_name('rcname')
  write(6,*)'program continues...'
end program name
Task: Program name

C: #include <stdio.h>

int main(int argc, char **argv) {
	printf("Executable: %s\n", argv[0]);

	return 0;
}









COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name



C#: using System;
namespace ProgramName
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.Write(Environment.CommandLine);
		}
	}
}







COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name


C++: #include <iostream>

using namespace std;

int main(int argc, char **argv) {
	char *program = argv[0];
	cout << "Program: " << program << endl;
}








COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name





Java: public class ScriptName {
	public static void main(String[] args) {
		String program = System.getProperty("sun.java.command").split(" ")[0];
		System.out.println("Program: " + program);
	}
}





COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name







Python: 

import sys

def main():
    program = sys.argv[0]
    print("Program: %s" % program)

if __name__ == "__main__":
    main()



COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name








VB: Debug.Print Application.Name


COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name




Go: package main

import (
    "fmt"
    "os"
)

func main() {
    fmt.Println("Program:", os.Args[0])
}






COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Program name






PHP: <?php
$program = $_SERVER["SCRIPT_NAME"];
echo "Program: $program\n";
?>
Task: Program name






PHP: <?php
$program = $_SERVER["SCRIPT_NAME"];
echo "Program: $program\n";
?>






Ada: with Ada.Command_Line, Ada.Text_IO;

procedure Command_Name is
begin
   Ada.Text_IO.Put_Line(Ada.Command_Line.Command_Name);
end Command_Name;
Task: Program name






PHP: <?php
$program = $_SERVER["SCRIPT_NAME"];
echo "Program: $program\n";
?>




COBOL:        identification division.
       program-id. sample.

       data division.
       working-storage section.
       01 progname pic x(16).

       procedure division.
       sample-main.

       display 0 upon argument-number
       accept progname from argument-value
       display "argument-value zero :" progname ":"

       display "function module-id  :" function module-id ":"

       goback.
       end program sample.
Task: Terminal control_Ringing the terminal bell



C#: 
System.Console.Write("\a"); 
System.Threading.Thread.Sleep(1000); 
System.Console.Beep(); 
System.Threading.Thread.Sleep(1000);


System.Console.Beep(440, 2000); 









Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell

C: #include <stdio.h>
int main() {
  printf("\a");
  return 0;
}











Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell


C++: #include <iostream>

int main() {
  std::cout << "\a";
  return 0;
}










Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell




Go: package main

import "fmt"

func main() {
  fmt.Print("\a")
}








Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell





Java: public class Bell{
    public static void main(String[] args){
        java.awt.Toolkit.getDefaultToolkit().beep();

        

        System.out.println((char)7);
    }
}







Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell







Python: print "\a"





Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell



C#: 
System.Console.Write("\a"); 
System.Threading.Thread.Sleep(1000); 
System.Console.Beep(); 
System.Threading.Thread.Sleep(1000);


System.Console.Beep(440, 2000);
Task: Terminal control_Ringing the terminal bell





Java: public class Bell{
    public static void main(String[] args){
        java.awt.Toolkit.getDefaultToolkit().beep();

        

        System.out.println((char)7);
    }
}
Task: Terminal control_Ringing the terminal bell


C++: #include <iostream>

int main() {
  std::cout << "\a";
  return 0;
}
Task: Terminal control_Ringing the terminal bell

C: #include <stdio.h>
int main() {
  printf("\a");
  return 0;
}
Task: Terminal control_Ringing the terminal bell




Go: package main

import "fmt"

func main() {
  fmt.Print("\a")
}
Task: Terminal control_Ringing the terminal bell







Python: print "\a"
Task: Terminal control_Ringing the terminal bell



C#: 
System.Console.Write("\a"); 
System.Threading.Thread.Sleep(1000); 
System.Console.Beep(); 
System.Threading.Thread.Sleep(1000);


System.Console.Beep(440, 2000); 







COBOL: DISPLAY SPACE WITH BELL
Task: Terminal control_Ringing the terminal bell





Java: public class Bell{
    public static void main(String[] args){
        java.awt.Toolkit.getDefaultToolkit().beep();

        

        System.out.println((char)7);
    }
}





COBOL: DISPLAY SPACE WITH BELL
Task: Terminal control_Ringing the terminal bell






PHP: <?php
echo "\007";






Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;

procedure Bell is
begin
   Put(Ada.Characters.Latin_1.BEL);
end Bell;
Task: Terminal control_Ringing the terminal bell






PHP: <?php
echo "\007";
Task: Doubly-linked list_Element insertion



C#: static void InsertAfter(Link prev, int i)
{
    if (prev.next != null)
    {
        prev.next.prev = new Link() { item = i, prev = prev, next = prev.next };
        prev.next = prev.next.prev;
    }
    else
        prev.next = new Link() { item = i, prev = prev };
}









Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion

C: void insert(link* anchor, link* newlink) {
  newlink->next = anchor->next;
  newlink->prev = anchor;
  (newlink->next)->prev = newlink;
  anchor->next = newlink;
}











Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion


C++: template <typename T>
void insert_after(Node<T>* N, T&& data)
{
    auto node = new Node<T>{N, N->next, std::forward(data)};
    if(N->next != nullptr)
        N->next->prev = node;
    N->next = node;
}










Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion




Go: package main

import "fmt"

type dlNode struct {
    string
    next, prev *dlNode
}

type dlList struct {
    head, tail *dlNode
}

func (list *dlList) String() string {
    if list.head == nil {
        return fmt.Sprint(list.head)
    }
    r := "[" + list.head.string
    for p := list.head.next; p != nil; p = p.next {
        r += " " + p.string
    }
    return r + "]"
}

func (list *dlList) insertTail(node *dlNode) {
    if list.tail == nil {
        list.head = node
    } else {
        list.tail.next = node
    }
    node.next = nil
    node.prev = list.tail
    list.tail = node
}

func (list *dlList) insertAfter(existing, insert *dlNode) {
    insert.prev = existing
    insert.next = existing.next
    existing.next.prev = insert
    existing.next = insert
    if existing == list.tail {
        list.tail = insert
    }
}

func main() {
    dll := &dlList{}
    fmt.Println(dll)
    a := &dlNode{string: "A"}
    dll.insertTail(a)
    dll.insertTail(&dlNode{string: "B"})
    fmt.Println(dll)
    dll.insertAfter(a, &dlNode{string: "C"})
    fmt.Println(dll)
}








Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion





Java: import java.util.LinkedList;

@SuppressWarnings("serial")
public class DoublyLinkedListInsertion<T> extends LinkedList<T> {
   
    public static void main(String[] args) {
        DoublyLinkedListInsertion<String> list = new DoublyLinkedListInsertion<String>();
        list.addFirst("Add First 1");
        list.addFirst("Add First 2");
        list.addFirst("Add First 3");
        list.addFirst("Add First 4");
        list.addFirst("Add First 5");
        traverseList(list);
        
        list.addAfter("Add First 3", "Add New");
        traverseList(list);
    }
    
    
    public void addAfter(T after, T element) {
        int index = indexOf(after);
        if ( index >= 0 ) {
            add(index + 1, element);
        }
        else {
            addLast(element);
        }
    }
    
    private static void traverseList(LinkedList<String> list) {
        System.out.println("Traverse List:");
        for ( int i = 0 ; i < list.size() ; i++ ) {
            System.out.printf("Element number %d - Element value = '%s'%n", i, list.get(i));
        }
        System.out.println();
    }
    
}







Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion







Python: def insert(anchor, new):
    new.next = anchor.next
    new.prev = anchor
    anchor.next.prev = new
    anchor.next = new





Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion








VB: Public Sub Insert(ByVal a As Node(Of T), ByVal b As Node(Of T), ByVal c As T)
    Dim node As New Node(Of T)(value)
    a.Next = node
    node.Previous = a
    b.Previous = node
    node.Next = b
End Sub




Ada: procedure Insert (Anchor : Link_Access; New_Link : Link_Access) is
begin
   if Anchor /= Null and New_Link /= Null then
      New_Link.Next := Anchor.Next;
      New_Link.Prev := Anchor;
      if New_Link.Next /= Null then
         New_Link.Next.Prev := New_Link;
      end if;
      Anchor.Next := New_Link;
   end if;
end Insert;
Task: Doubly-linked list_Element insertion

C: void insert(link* anchor, link* newlink) {
  newlink->next = anchor->next;
  newlink->prev = anchor;
  (newlink->next)->prev = newlink;
  anchor->next = newlink;
}
Task: Doubly-linked list_Element insertion



C#: static void InsertAfter(Link prev, int i)
{
    if (prev.next != null)
    {
        prev.next.prev = new Link() { item = i, prev = prev, next = prev.next };
        prev.next = prev.next.prev;
    }
    else
        prev.next = new Link() { item = i, prev = prev };
}
Task: Doubly-linked list_Element insertion


C++: template <typename T>
void insert_after(Node<T>* N, T&& data)
{
    auto node = new Node<T>{N, N->next, std::forward(data)};
    if(N->next != nullptr)
        N->next->prev = node;
    N->next = node;
}
Task: Doubly-linked list_Element insertion





Java: import java.util.LinkedList;

@SuppressWarnings("serial")
public class DoublyLinkedListInsertion<T> extends LinkedList<T> {
   
    public static void main(String[] args) {
        DoublyLinkedListInsertion<String> list = new DoublyLinkedListInsertion<String>();
        list.addFirst("Add First 1");
        list.addFirst("Add First 2");
        list.addFirst("Add First 3");
        list.addFirst("Add First 4");
        list.addFirst("Add First 5");
        traverseList(list);
        
        list.addAfter("Add First 3", "Add New");
        traverseList(list);
    }
    
    
    public void addAfter(T after, T element) {
        int index = indexOf(after);
        if ( index >= 0 ) {
            add(index + 1, element);
        }
        else {
            addLast(element);
        }
    }
    
    private static void traverseList(LinkedList<String> list) {
        System.out.println("Traverse List:");
        for ( int i = 0 ; i < list.size() ; i++ ) {
            System.out.printf("Element number %d - Element value = '%s'%n", i, list.get(i));
        }
        System.out.println();
    }
    
}
Task: Doubly-linked list_Element insertion







Python: def insert(anchor, new):
    new.next = anchor.next
    new.prev = anchor
    anchor.next.prev = new
    anchor.next = new
Task: Doubly-linked list_Element insertion








VB: Public Sub Insert(ByVal a As Node(Of T), ByVal b As Node(Of T), ByVal c As T)
    Dim node As New Node(Of T)(value)
    a.Next = node
    node.Previous = a
    b.Previous = node
    node.Next = b
End Sub