WeixiangYan/CodeTransOcean huggingface dataset:
Task: Generic swap








VB: sub swap( byref x, byref y )
	dim temp
	temp = x
	x = y
	y = temp
end sub



Fortran: MODULE Genericswap
  IMPLICIT NONE

  INTERFACE Swap
    MODULE PROCEDURE Swapint, Swapreal, Swapstring
  END INTERFACE

CONTAINS

  SUBROUTINE Swapint(a, b)
    INTEGER, INTENT(IN OUT) :: a, b
    INTEGER :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapint

  SUBROUTINE Swapreal(a, b)
    REAL, INTENT(IN OUT) :: a, b
    REAL :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapreal

  SUBROUTINE Swapstring(a, b)
    CHARACTER(*), INTENT(IN OUT) :: a, b
    CHARACTER(len(a)) :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapstring
END MODULE Genericswap

PROGRAM EXAMPLE
  USE Genericswap
  IMPLICIT NONE
  INTEGER :: i1 = 1, i2 = 2
  REAL :: r1 = 1.0, r2 = 2.0
  CHARACTER(3) :: s1="abc", s2="xyz"

  CALL Swap(i1, i2)
  CALL Swap(r1, r2)
  CALL Swap(s1, s2)

  WRITE(*,*) i1, i2   
  WRITE(*,*) r1, r2   
  WRITE(*,*) s1, s2   
END PROGRAM EXAMPLE
Task: Generic swap






PHP: function swap(&$a, &$b) {
    list($a, $b) = array($b, $a);
}





Fortran: MODULE Genericswap
  IMPLICIT NONE

  INTERFACE Swap
    MODULE PROCEDURE Swapint, Swapreal, Swapstring
  END INTERFACE

CONTAINS

  SUBROUTINE Swapint(a, b)
    INTEGER, INTENT(IN OUT) :: a, b
    INTEGER :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapint

  SUBROUTINE Swapreal(a, b)
    REAL, INTENT(IN OUT) :: a, b
    REAL :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapreal

  SUBROUTINE Swapstring(a, b)
    CHARACTER(*), INTENT(IN OUT) :: a, b
    CHARACTER(len(a)) :: temp
    temp = a ; a = b ; b = temp
  END SUBROUTINE Swapstring
END MODULE Genericswap

PROGRAM EXAMPLE
  USE Genericswap
  IMPLICIT NONE
  INTEGER :: i1 = 1, i2 = 2
  REAL :: r1 = 1.0, r2 = 2.0
  CHARACTER(3) :: s1="abc", s2="xyz"

  CALL Swap(i1, i2)
  CALL Swap(r1, r2)
  CALL Swap(s1, s2)

  WRITE(*,*) i1, i2   
  WRITE(*,*) r1, r2   
  WRITE(*,*) s1, s2   
END PROGRAM EXAMPLE
Task: Generic swap

C: void swap(void *va, void *vb, size_t s)
{
  char t, *a = (char*)va, *b = (char*)vb;
  while(s--)
    t = a[s], a[s] = b[s], b[s] = t;
}









COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap



C#: static void Swap<T>(ref T a, ref T b)
{
    T temp = a;
    a = b;
    b = temp;
}







COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap


C++: template<typename T> void swap(T& left, T& right)
{
  T tmp(left);
  left = right;
  right = tmp;
}








COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap





Java: class Pair<T> {
    T first;
    T second;
}
public static <T> void swap(Pair<T> p) {
   T temp = p.first;
   p.first = p.second;
   p.second = temp;
}





COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap







Python: a, b = b, a



COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap








VB: sub swap( byref x, byref y )
	dim temp
	temp = x
	x = y
	y = temp
end sub


COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap




Go: a, b = b, a






COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Generic swap






PHP: function swap(&$a, &$b) {
    list($a, $b) = array($b, $a);
}
Task: Generic swap






PHP: function swap(&$a, &$b) {
    list($a, $b) = array($b, $a);
}






Ada: generic
   type Swap_Type is private; 
procedure Generic_Swap (Left, Right : in out Swap_Type);

procedure Generic_Swap (Left, Right : in out Swap_Type) is
   Temp : constant Swap_Type := Left;
begin
   Left := Right;
   Right := Temp;
end Generic_Swap;
Task: Generic swap






PHP: function swap(&$a, &$b) {
    list($a, $b) = array($b, $a);
}




COBOL:        PROGRAM-ID. SWAP-DEMO.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   A simple program to demonstrate the SWAP subprogram.
      **     
      ************************************************************
       
       DATA DIVISION.
       
       WORKING-STORAGE SECTION.
       
       01  Val1                 PIC X(72).
       01  Val2                 PIC X(72).
       
       PROCEDURE DIVISION.
       
       Main-Program.

          DISPLAY 'Enter a Value: ' WITH NO ADVANCING.
          ACCEPT Val1.
          DISPLAY 'Enter another Value: ' WITH NO ADVANCING.
          ACCEPT Val2.
          DISPLAY ' ' .
          DISPLAY 'First value: ' FUNCTION TRIM(Val1) .
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2) .

           CALL "SWAP" USING BY REFERENCE Val1,  BY REFERENCE Val2.

          DISPLAY ' '.
          DISPLAY 'After SWAP '.
          DISPLAY ' '.
          DISPLAY 'First value: ' FUNCTION TRIM(Val1).
          DISPLAY 'Second value: ' FUNCTION TRIM(Val2).

           STOP RUN.
       
       END PROGRAM SWAP-DEMO.
       
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SWAP.
       AUTHOR.  Bill Gunshannon.
       INSTALLATION.  Home.
       DATE-WRITTEN.  16 December 2021.
      ************************************************************
      ** Program Abstract:
      **   SWAP any Alphanumeric value.  Only limit is 72
      **     character size.  But that can be adjusted for
      **     whatever use one needs.
      ************************************************************

       DATA DIVISION.

       WORKING-STORAGE SECTION.

       01  TEMP                  PIC X(72).

       LINKAGE SECTION.

       01  Field1                PIC X(72).
       01  Field2                PIC X(72).

       PROCEDURE DIVISION 
               USING BY REFERENCE Field1, BY REFERENCE Field2.

       MOVE Field1 to TEMP.
       MOVE Field2 to Field1.
       MOVE TEMP to Field2.

       GOBACK.

       END PROGRAM SWAP.
Task: Elementary cellular automaton

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

typedef unsigned long long ull;
#define N  (sizeof(ull) * CHAR_BIT)
#define B(x) (1ULL << (x))

void evolve(ull state, int rule)
{
	int i;
	ull st;

	printf("Rule %d:\n", rule);
	do {
		st = state;
		for (i = N; i--; ) putchar(st & B(i) ? '#' : '.');
		putchar('\n');

		for (state = i = 0; i < N; i++)
			if (rule & B(7 & (st>>(i-1) | st<<(N+1-i))))
				state |= B(i);
	} while (st != state);
}

int main(int argc, char **argv)
{
	evolve(B(N/2), 90);
	evolve(B(N/4)|B(N - N/4), 30); 

	return 0;
}











Ada: with Ada.Text_IO;
procedure Elementary_Cellular_Automaton is
   
   type t_Rule  is new Integer range 0..2**8-1;
   type t_State is array (Integer range <>) of Boolean;

   Cell_Image : constant array (Boolean) of Character := ('.', '#');

   function Image (State : in t_State) return String is
     (Cell_Image(State(State'First)) &
      (if State'Length <= 1 then ""
       else Image(State(State'First+1..State'Last))));

   
   type t_RuleA is array (Boolean, Boolean, Boolean) of Boolean;

   function Translate (Rule : in t_Rule) return t_RuleA is
      
      
      Remain : t_Rule := Rule;
   begin
      return Answer : t_RuleA do
         for K in Boolean loop
            for J in Boolean loop
               for I in Boolean loop
                  Answer(I,J,K) := (Remain mod 2 = 1);
                  Remain := Remain / 2;
               end loop;
            end loop;
         end loop;
      end return;
   end Translate;

   procedure Show_Automaton (Rule        : in t_Rule;
                             Initial     : in t_State;
                             Generations : in Positive) is
      RuleA : constant t_RuleA  := Translate(Rule);
      Width : constant Positive := Initial'Length;
      
      subtype t_State0 is t_State (0..Width-1);
      State     : t_State0 := Initial;
      New_State : t_State0;
   begin
      Ada.Text_IO.Put_Line ("Rule" & t_Rule'Image(Rule) & " :");
      for Generation in 1..Generations loop
         Ada.Text_IO.Put_Line (Image(State));
         for Cell in State'Range loop
            New_State(Cell) := RuleA(State((Cell-1) mod Width),
                                     State(Cell),
                                     State((Cell+1) mod Width));
         end loop;
         State := New_State;
      end loop;
   end Show_Automaton;

begin
   Show_Automaton (Rule        => 90,
                   Initial     => (-10..-1 => False, 0 => True, 1..10 => False),
                   Generations => 15);
   Show_Automaton (Rule        => 30,
                   Initial     => (-15..-1 => False, 0 => True, 1..15 => False),
                   Generations => 20);
   Show_Automaton (Rule        => 122,
                   Initial     => (-12..-1 => False, 0 => True, 1..12 => False),
                   Generations => 25);
end Elementary_Cellular_Automaton;