WeixiangYan/CodeTransOcean huggingface dataset:
Task: Topological sort







Python: try:
    from functools import reduce
except:
    pass

data = {
    'des_system_lib':   set('std synopsys std_cell_lib des_system_lib dw02 dw01 ramlib ieee'.split()),
    'dw01':             set('ieee dw01 dware gtech'.split()),
    'dw02':             set('ieee dw02 dware'.split()),
    'dw03':             set('std synopsys dware dw03 dw02 dw01 ieee gtech'.split()),
    'dw04':             set('dw04 ieee dw01 dware gtech'.split()),
    'dw05':             set('dw05 ieee dware'.split()),
    'dw06':             set('dw06 ieee dware'.split()),
    'dw07':             set('ieee dware'.split()),
    'dware':            set('ieee dware'.split()),
    'gtech':            set('ieee gtech'.split()),
    'ramlib':           set('std ieee'.split()),
    'std_cell_lib':     set('ieee std_cell_lib'.split()),
    'synopsys':         set(),
    }

def toposort2(data):
    for k, v in data.items():
        v.discard(k) 
    extra_items_in_deps = reduce(set.union, data.values()) - set(data.keys())
    data.update({item:set() for item in extra_items_in_deps})
    while True:
        ordered = set(item for item,dep in data.items() if not dep)
        if not ordered:
            break
        yield ' '.join(sorted(ordered))
        data = {item: (dep - ordered) for item,dep in data.items()
                if item not in ordered}
    assert not data, "A cyclic dependency exists amongst %r" % data

print ('\n'.join( toposort2(data) ))




Fortran:       SUBROUTINE TSORT(NL,ND,IDEP,IORD,IPOS,NO)
      IMPLICIT NONE
      INTEGER NL,ND,NO,IDEP(ND,2),IORD(NL),IPOS(NL),I,J,K,IL,IR,IPL,IPR
      DO 10 I=1,NL
      IORD(I)=I
   10 IPOS(I)=I
      K=1
   20 J=K
      K=NL+1
      DO 30 I=1,ND
      IL=IDEP(I,1)
      IR=IDEP(I,2)
      IPL=IPOS(IL)
      IPR=IPOS(IR)
      IF(IL.EQ.IR .OR. IPL.GE.K .OR. IPL.LT.J .OR. IPR.LT.J) GO TO 30
      K=K-1
      IPOS(IORD(K))=IPL
      IPOS(IL)=K
      IORD(IPL)=IORD(K)
      IORD(K)=IL
   30 CONTINUE
      IF(K.GT.J) GO TO 20
      NO=J-1
      END
Task: Topological sort








VB: class topological
	dim dictDependencies
	dim dictReported
	dim depth
	
	sub class_initialize
		set dictDependencies = createobject("Scripting.Dictionary")
		set dictReported = createobject("Scripting.Dictionary")
		depth = 0
	end sub
	
	sub reset
		dictReported.removeall
	end sub
	
	property let dependencies( s )
		
		dim i, j ,k
		dim aList
		dim dep
		dim a1
		aList = Split( s, vbNewLine )
		
		do while aList( UBound( aList ) ) = vbnullstring
			redim preserve aList( UBound( aList ) - 1 )
		loop

		for i = lbound( aList ) to ubound( aList )
			aList( i ) = Split( aList( i ), vbTab, 2 )
			a1 = Split( aList( i )( 1 ), " " )
			k = 0
			for j = lbound( a1) to ubound(a1)
				if a1(j) <> aList(i)(0) then
					a1(k) = a1(j)
					k = k + 1
				end if
			next
			redim preserve a1(k-1)
			aList(i)(1) = a1
		next
		for i = lbound( aList ) to ubound( aList )
			dep = aList(i)(0)
			if not dictDependencies.Exists( dep ) then
				dictDependencies.add dep, aList(i)(1)
			end if
		next
		
	end property
	
	sub resolve( s )
		dim i 
		dim deps
		
		depth = depth + 1
		if dictDependencies.Exists(s) then
			deps = dictDependencies(s)
			for i = lbound(deps) to ubound(deps)
				resolve deps(i)
			next
		end if
		if not seen(s) then
			wscript.echo s
			see s
		end if
		depth = depth - 1
	end sub

	function seen( key )
		seen = dictReported.Exists( key )
	end function
	
	sub see( key )
		dictReported.add key, ""
	end sub
	
	property get keys
		keys = dictDependencies.keys
	end property
end class



Fortran:       SUBROUTINE TSORT(NL,ND,IDEP,IORD,IPOS,NO)
      IMPLICIT NONE
      INTEGER NL,ND,NO,IDEP(ND,2),IORD(NL),IPOS(NL),I,J,K,IL,IR,IPL,IPR
      DO 10 I=1,NL
      IORD(I)=I
   10 IPOS(I)=I
      K=1
   20 J=K
      K=NL+1
      DO 30 I=1,ND
      IL=IDEP(I,1)
      IR=IDEP(I,2)
      IPL=IPOS(IL)
      IPR=IPOS(IR)
      IF(IL.EQ.IR .OR. IPL.GE.K .OR. IPL.LT.J .OR. IPR.LT.J) GO TO 30
      K=K-1
      IPOS(IORD(K))=IPL
      IPOS(IL)=K
      IORD(IPL)=IORD(K)
      IORD(K)=IL
   30 CONTINUE
      IF(K.GT.J) GO TO 20
      NO=J-1
      END
Task: Formatted numeric output



C#: class Program
    {


        static void Main(string[] args)
        {

            float myNumbers = 7.125F;
            
            string strnumber = Convert.ToString(myNumbers);
                       
            Console.WriteLine(strnumber.PadLeft(9, '0'));
           
            Console.ReadLine();
        }
        

             
       
    }









Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output

C: #include <stdio.h>
main(){
  float r=7.125;
  printf(" %9.3f\n",-r);
  printf(" %9.3f\n",r);
  printf(" %-9.3f\n",r);
  printf(" %09.3f\n",-r);
  printf(" %09.3f\n",r);
  printf(" %-09.3f\n",r);
  return 0;
}











Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output


C++: #include <iostream>
#include <iomanip>

int main()
{
  std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl;
  return 0;
}










Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output




Go: fmt.Printf("%09.3f", 7.125)








Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output





Java: public class Printing{
	public static void main(String[] args){
		double value = 7.125;
		System.out.printf("%09.3f",value); 
		System.out.println(String.format("%09.3f",value));
	}
}







Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output







Python: from math import pi, exp
r = exp(pi)-pi
print r
print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r)
print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r)
print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r)





Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output








VB: Option Explicit

Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub

Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String



Dim u As String, v As String, i As Integer
   u = CStr(Nb)
   i = InStr(u, Application.DecimalSeparator)
   If i > 0 Then
      v = Mid(u, i + 1)
      u = Left(u, i - 1)
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
   Else
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
   End If
End Function




Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output

C: #include <stdio.h>
main(){
  float r=7.125;
  printf(" %9.3f\n",-r);
  printf(" %9.3f\n",r);
  printf(" %-9.3f\n",r);
  printf(" %09.3f\n",-r);
  printf(" %09.3f\n",r);
  printf(" %-09.3f\n",r);
  return 0;
}
Task: Formatted numeric output



C#: class Program
    {


        static void Main(string[] args)
        {

            float myNumbers = 7.125F;
            
            string strnumber = Convert.ToString(myNumbers);
                       
            Console.WriteLine(strnumber.PadLeft(9, '0'));
           
            Console.ReadLine();
        }
        

             
       
    }
Task: Formatted numeric output


C++: #include <iostream>
#include <iomanip>

int main()
{
  std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl;
  return 0;
}
Task: Formatted numeric output





Java: public class Printing{
	public static void main(String[] args){
		double value = 7.125;
		System.out.printf("%09.3f",value); 
		System.out.println(String.format("%09.3f",value));
	}
}
Task: Formatted numeric output







Python: from math import pi, exp
r = exp(pi)-pi
print r
print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r)
print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r)
print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r)
Task: Formatted numeric output








VB: Option Explicit

Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub

Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String



Dim u As String, v As String, i As Integer
   u = CStr(Nb)
   i = InStr(u, Application.DecimalSeparator)
   If i > 0 Then
      v = Mid(u, i + 1)
      u = Left(u, i - 1)
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
   Else
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
   End If
End Function
Task: Formatted numeric output




Go: fmt.Printf("%09.3f", 7.125)
Task: Formatted numeric output



C#: class Program
    {


        static void Main(string[] args)
        {

            float myNumbers = 7.125F;
            
            string strnumber = Convert.ToString(myNumbers);
                       
            Console.WriteLine(strnumber.PadLeft(9, '0'));
           
            Console.ReadLine();
        }
        

             
       
    }








Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output


C++: #include <iostream>
#include <iomanip>

int main()
{
  std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl;
  return 0;
}









Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output

C: #include <stdio.h>
main(){
  float r=7.125;
  printf(" %9.3f\n",-r);
  printf(" %9.3f\n",r);
  printf(" %-9.3f\n",r);
  printf(" %09.3f\n",-r);
  printf(" %09.3f\n",r);
  printf(" %-09.3f\n",r);
  return 0;
}










Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output





Java: public class Printing{
	public static void main(String[] args){
		double value = 7.125;
		System.out.printf("%09.3f",value); 
		System.out.println(String.format("%09.3f",value));
	}
}






Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output







Python: from math import pi, exp
r = exp(pi)-pi
print r
print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r)
print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r)
print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r)




Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output








VB: Option Explicit

Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub

Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String



Dim u As String, v As String, i As Integer
   u = CStr(Nb)
   i = InStr(u, Application.DecimalSeparator)
   If i > 0 Then
      v = Mid(u, i + 1)
      u = Left(u, i - 1)
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
   Else
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
   End If
End Function



Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output






PHP: echo str_pad(7.125, 9, '0', STR_PAD_LEFT);





Fortran: INTEGER :: number = 7125
WRITE(*,"(I8.8)") number
Task: Formatted numeric output

C: #include <stdio.h>
main(){
  float r=7.125;
  printf(" %9.3f\n",-r);
  printf(" %9.3f\n",r);
  printf(" %-9.3f\n",r);
  printf(" %09.3f\n",-r);
  printf(" %09.3f\n",r);
  printf(" %-09.3f\n",r);
  return 0;
}









COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output



C#: class Program
    {


        static void Main(string[] args)
        {

            float myNumbers = 7.125F;
            
            string strnumber = Convert.ToString(myNumbers);
                       
            Console.WriteLine(strnumber.PadLeft(9, '0'));
           
            Console.ReadLine();
        }
        

             
       
    }







COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output


C++: #include <iostream>
#include <iomanip>

int main()
{
  std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125 << std::endl;
  return 0;
}








COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output





Java: public class Printing{
	public static void main(String[] args){
		double value = 7.125;
		System.out.printf("%09.3f",value); 
		System.out.println(String.format("%09.3f",value));
	}
}





COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output







Python: from math import pi, exp
r = exp(pi)-pi
print r
print "e=%e f=%f g=%g G=%G s=%s r=%r!"%(r,r,r,r,r,r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(-r,-r,-r)
print "e=%9.4e f=%9.4f g=%9.4g!"%(r,r,r)
print "e=%-9.4e f=%-9.4f g=%-9.4g!"%(r,r,r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(-r,-r,-r)
print "e=%09.4e f=%09.4f g=%09.4g!"%(r,r,r)
print "e=%-09.4e f=%-09.4f g=%-09.4g!"%(r,r,r)



COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output








VB: Option Explicit

Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub

Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String



Dim u As String, v As String, i As Integer
   u = CStr(Nb)
   i = InStr(u, Application.DecimalSeparator)
   If i > 0 Then
      v = Mid(u, i + 1)
      u = Left(u, i - 1)
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
   Else
      fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
   End If
End Function


COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output




Go: fmt.Printf("%09.3f", 7.125)






COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Formatted numeric output






PHP: echo str_pad(7.125, 9, '0', STR_PAD_LEFT);
Task: Formatted numeric output






PHP: echo str_pad(7.125, 9, '0', STR_PAD_LEFT);






Ada: with Ada.Text_Io.Editing; use Ada.Text_Io.Editing;
with Ada.Text_Io; use Ada.Text_Io;

procedure Zero_Fill is
   Pic_String: String := "<999999.99>";
   Pic : Picture := To_Picture(Pic_String);
   type Money is delta 0.01 digits 8;
   package Money_Output is new Decimal_Output(Money);
   use Money_Output;
   
   Value : Money := 37.25;
begin
   Put(Item => Value, Pic => Pic);
end Zero_Fill;
Task: Formatted numeric output






PHP: echo str_pad(7.125, 9, '0', STR_PAD_LEFT);




COBOL: IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01  WS-EXAMPLE.
    05 X            PIC  9(5)V9(3).
PROCEDURE DIVISION.
    MOVE     7.125  TO   X.
    DISPLAY  X      UPON CONSOLE.
    STOP RUN.
Task: Doubly-linked list_Element definition



C#: class Link
{
    public int Item { get; set; }
    public Link Prev { get; set; }
    public Link Next { get; set; }

    
    public Link(int item, Link prev = null, Link next = null) {
        Item = item;
        Prev = prev;
        Next = next;
    }
}









Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition

C: struct Node 
{
  struct Node *next;
  struct Node *prev;
  void  *data;
};











Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition


C++: template <typename T>
struct Node
{
    Node* next;
    Node* prev;
    T data;
};










Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition




Go: type dlNode struct {
    string
    next, prev *dlNode
}








Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition





Java: public class Node<T> {
   private T element;
   private Node<T> next, prev;

   public Node<T>(){
      next = prev = element = null;
   }

   public Node<T>(Node<T> n, Node<T> p, T elem){
      next = n;
      prev = p;
      element = elem;
   }

   public void setNext(Node<T> n){
      next = n;
   }

   public Node<T> getNext(){
      return next;
   }

   public void setElem(T elem){
      element = elem;
   }

   public T getElem(){
      return element;
   }

   public void setNext(Node<T> n){
      next = n;
   }

   public Node<T> setPrev(Node<T> p){
      prev = p;
   }

   public getPrev(){
      return prev;
   }
}







Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition







Python: class Node(object):
     def __init__(self, data = None, prev = None, next = None):
         self.prev = prev
         self.next = next
         self.data = data
     def __str__(self):
         return str(self.data)
     def __repr__(self):
         return repr(self.data)
     def iter_forward(self):
         c = self
         while c != None:
             yield c
             c = c.next
     def iter_backward(self):
         c = self
         while c != None:
             yield c
             c = c.prev





Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition








VB: Public Class Node(Of T)
   Public Value As T
   Public [Next] As Node(Of T)
   Public Previous As Node(Of T)
End Class




Ada: type Link;
type Link_Access is access Link;
type Link is record
  Next : Link_Access := null;
  Prev : Link_Access := null;
  Data : Integer;
end record;
Task: Doubly-linked list_Element definition

C: struct Node 
{
  struct Node *next;
  struct Node *prev;
  void  *data;
};
Task: Doubly-linked list_Element definition



C#: class Link
{
    public int Item { get; set; }
    public Link Prev { get; set; }
    public Link Next { get; set; }

    
    public Link(int item, Link prev = null, Link next = null) {
        Item = item;
        Prev = prev;
        Next = next;
    }
}
Task: Doubly-linked list_Element definition


C++: template <typename T>
struct Node
{
    Node* next;
    Node* prev;
    T data;
};
Task: Doubly-linked list_Element definition





Java: public class Node<T> {
   private T element;
   private Node<T> next, prev;

   public Node<T>(){
      next = prev = element = null;
   }

   public Node<T>(Node<T> n, Node<T> p, T elem){
      next = n;
      prev = p;
      element = elem;
   }

   public void setNext(Node<T> n){
      next = n;
   }

   public Node<T> getNext(){
      return next;
   }

   public void setElem(T elem){
      element = elem;
   }

   public T getElem(){
      return element;
   }

   public void setNext(Node<T> n){
      next = n;
   }

   public Node<T> setPrev(Node<T> p){
      prev = p;
   }

   public getPrev(){
      return prev;
   }
}