WeixiangYan/CodeTransOcean huggingface dataset:
Task: Loops_For with a specified step







Python: for i in xrange(2, 9, 2):
    print "%d," % i,
print "who do we appreciate?"




Fortran: do i = 1,10,2
   print *, i
end do
Task: Loops_For with a specified step








VB: Sub MyLoop()
    For i = 2 To 8 Step 2
        Debug.Print i;
    Next i
    Debug.Print
End Sub



Fortran: do i = 1,10,2
   print *, i
end do
Task: Loops_For with a specified step






PHP: <?php
foreach (range(2, 8, 2) as $i)
    echo "$i, ";
echo "who do we appreciate?\n";
?>





Fortran: do i = 1,10,2
   print *, i
end do
Task: Loops_For with a specified step

C: int i;
for(i = 1; i < 10; i += 2)
  printf("%d\n", i);









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step



C#: using System;
 
class Program {
    static void Main(string[] args) {    
        for (int i = 2; i <= 8; i+= 2) {        
            Console.Write("{0}, ", i);
        }

        Console.WriteLine("who do we appreciate?");
    }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step


C++: for (int i = 1; i < 10; i += 2)
  std::cout << i << std::endl;








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step





Java: for(int i = 2; i <= 8;i += 2){
   System.out.print(i + ", ");
}
System.out.println("who do we appreciate?");





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step







Python: for i in xrange(2, 9, 2):
    print "%d," % i,
print "who do we appreciate?"



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step








VB: Sub MyLoop()
    For i = 2 To 8 Step 2
        Debug.Print i;
    Next i
    Debug.Print
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step




Go: for i := 1; i < 10; i += 2 {
  fmt.Printf("%d\n", i)
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Loops_For with a specified step






PHP: <?php
foreach (range(2, 8, 2) as $i)
    echo "$i, ";
echo "who do we appreciate?\n";
?>
Task: Loops_For with a specified step






PHP: <?php
foreach (range(2, 8, 2) as $i)
    echo "$i, ";
echo "who do we appreciate?\n";
?>






Ada: with Loopers;
use Loopers;


procedure For_Main is
begin
        Looper_1;
        Looper_2;
        Looper_3;
end For_Main;


package Loopers is
        procedure Looper_1;
        procedure Looper_2;
        procedure Looper_3;
end Loopers;

with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;

package body Loopers is
        procedure Looper_1 is
                Values : array(1..5) of Integer := (2,4,6,8,10);
        begin
                for I in Values'Range loop
                        Put(Values(I),0);
                        if I = Values'Last then
                                Put_Line(".");
                        else
                                Put(",");
                        end if;
                end loop;
        end Looper_1;

        procedure Looper_2 is
                E : Integer := 5;
        begin
                for I in 1..E loop
                        Put(I*2,0);
                        if I = E then
                                Put_Line(".");
                        else
                                Put(",");
                        end if;
                end loop;
        end Looper_2;

        procedure Looper_3 is
                Values : array(1..10) of Integer := (1,2,3,4,5,6,7,8,9,10);
                Indices : array(1..5) of Integer := (2,4,6,8,10);
        begin
                for I in Indices'Range loop
                        Put(Values(Indices(I)),0);
                        if I = Indices'Last then
                                Put_Line(".");
                        else
                                Put(",");
                        end if;
                end loop;
        end Looper_3;

end Loopers;
Task: Loops_For with a specified step






PHP: <?php
foreach (range(2, 8, 2) as $i)
    echo "$i, ";
echo "who do we appreciate?\n";
?>




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Display-Odd-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  I PIC 99.

       PROCEDURE DIVISION.
           PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
               DISPLAY I
           END-PERFORM

           GOBACK
           .
Task: Queue_Usage



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

namespace RosettaCode
{
    class Program
    {
        static void Main()
        {
            
            Queue<int> queue  = new Queue<int>();
            queue.Enqueue(1);
            queue.Enqueue(3);
            queue.Enqueue(5);

            
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 

            
            bool empty = queue.Count == 0;
            Console.WriteLine(empty); 

            
            
            try
            {
                queue.Dequeue();
            }
            catch (InvalidOperationException exception)
            {
                Console.WriteLine(exception.Message); 
            }
        }
    }
}









Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage

C: #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
 
#include <sys/queue.h>



int main()
{
  int i;
  FIFOList head;

  TAILQ_INIT(&head);

  
  for(i=0; i < 20; i++) {
    m_enqueue(i, &head);
  }

  
  while( m_dequeue(&i, &head) )
    printf("%d\n", i);

  fprintf(stderr, "FIFO list %s\n",
      ( m_dequeue(&i, &head) ) ? 
      "had still an element" :
      "is void!");

  exit(0);
}











Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage


C++: #include <queue>
#include <cassert> 

int main()
{
  std::queue<int> q;
  assert( q.empty() );        

  q.push(1);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(2);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(3);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.pop();                    
  assert( !q.empty() );       
  assert( q.front() == 2);    

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 3);

  q.push(4);
  assert( !q.empty() );
  assert( q.front() == 3);

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 4);

  q.pop();
  assert( q.empty() );

  q.push(5);
  assert( !q.empty() );
  assert( q.front() == 5);

  q.pop();
  assert( q.empty() );
}










Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage




Go: package main

import (
    "fmt"
    "queue"
)

func main() {
    q := new(queue.Queue)
    fmt.Println("empty?", q.Empty())

    x := "black"
    fmt.Println("push", x)
    q.Push(x)

    fmt.Println("empty?", q.Empty())
    r, ok := q.Pop()
    if ok {
        fmt.Println(r, "popped")
    } else {
        fmt.Println("pop failed")
    }

    var n int
    for _, x := range []string{"blue", "red", "green"} {
        fmt.Println("pushing", x)
        q.Push(x)
        n++
    }

    for i := 0; i < n; i++ {
        r, ok := q.Pop()
        if ok {
            fmt.Println(r, "popped")
        } else {
            fmt.Println("pop failed")
        }
    }
}








Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage





Java: import java.util.LinkedList;
import java.util.Queue;
...
Queue<Integer> queue = new LinkedList<Integer>();
System.out.println(queue.isEmpty());      

queue.add(1);
queue.add(2);
queue.add(3);
System.out.println(queue);                
System.out.println(queue.remove());       
System.out.println(queue);                
System.out.println(queue.isEmpty());      







Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage







Python: let my_queue = Queue()

my_queue.push!('foo')
my_queue.push!('bar')
my_queue.push!('baz')

print my_queue.pop!() 
print my_queue.pop!() 
print my_queue.pop!() 





Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage








VB: Public Sub fifo()
    push "One"
    push "Two"
    push "Three"
    Debug.Print pop, pop, pop, empty_
End Sub




Ada: with FIFO;
with Ada.Text_Io; use Ada.Text_Io;
 
procedure Queue_Test is
   package Int_FIFO is new FIFO (Integer);
   use Int_FIFO;
   Queue : FIFO_Type;
   Value : Integer;
begin
   Push (Queue, 1);
   Push (Queue, 2);   
   Push (Queue, 3);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 4);
   Pop (Queue, Value);
   Pop (Queue, Value);
   Push (Queue, 5);
   Pop (Queue, Value);
   Put_Line ("Is_Empty " & Boolean'Image (Is_Empty (Queue)));
end Queue_Test;
Task: Queue_Usage

C: #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
 
#include <sys/queue.h>



int main()
{
  int i;
  FIFOList head;

  TAILQ_INIT(&head);

  
  for(i=0; i < 20; i++) {
    m_enqueue(i, &head);
  }

  
  while( m_dequeue(&i, &head) )
    printf("%d\n", i);

  fprintf(stderr, "FIFO list %s\n",
      ( m_dequeue(&i, &head) ) ? 
      "had still an element" :
      "is void!");

  exit(0);
}
Task: Queue_Usage



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

namespace RosettaCode
{
    class Program
    {
        static void Main()
        {
            
            Queue<int> queue  = new Queue<int>();
            queue.Enqueue(1);
            queue.Enqueue(3);
            queue.Enqueue(5);

            
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 

            
            bool empty = queue.Count == 0;
            Console.WriteLine(empty); 

            
            
            try
            {
                queue.Dequeue();
            }
            catch (InvalidOperationException exception)
            {
                Console.WriteLine(exception.Message); 
            }
        }
    }
}
Task: Queue_Usage


C++: #include <queue>
#include <cassert> 

int main()
{
  std::queue<int> q;
  assert( q.empty() );        

  q.push(1);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(2);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(3);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.pop();                    
  assert( !q.empty() );       
  assert( q.front() == 2);    

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 3);

  q.push(4);
  assert( !q.empty() );
  assert( q.front() == 3);

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 4);

  q.pop();
  assert( q.empty() );

  q.push(5);
  assert( !q.empty() );
  assert( q.front() == 5);

  q.pop();
  assert( q.empty() );
}
Task: Queue_Usage





Java: import java.util.LinkedList;
import java.util.Queue;
...
Queue<Integer> queue = new LinkedList<Integer>();
System.out.println(queue.isEmpty());      

queue.add(1);
queue.add(2);
queue.add(3);
System.out.println(queue);                
System.out.println(queue.remove());       
System.out.println(queue);                
System.out.println(queue.isEmpty());
Task: Queue_Usage







Python: let my_queue = Queue()

my_queue.push!('foo')
my_queue.push!('bar')
my_queue.push!('baz')

print my_queue.pop!() 
print my_queue.pop!() 
print my_queue.pop!()
Task: Queue_Usage








VB: Public Sub fifo()
    push "One"
    push "Two"
    push "Three"
    Debug.Print pop, pop, pop, empty_
End Sub
Task: Queue_Usage




Go: package main

import (
    "fmt"
    "queue"
)

func main() {
    q := new(queue.Queue)
    fmt.Println("empty?", q.Empty())

    x := "black"
    fmt.Println("push", x)
    q.Push(x)

    fmt.Println("empty?", q.Empty())
    r, ok := q.Pop()
    if ok {
        fmt.Println(r, "popped")
    } else {
        fmt.Println("pop failed")
    }

    var n int
    for _, x := range []string{"blue", "red", "green"} {
        fmt.Println("pushing", x)
        q.Push(x)
        n++
    }

    for i := 0; i < n; i++ {
        r, ok := q.Pop()
        if ok {
            fmt.Println(r, "popped")
        } else {
            fmt.Println("pop failed")
        }
    }
}
Task: Queue_Usage



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

namespace RosettaCode
{
    class Program
    {
        static void Main()
        {
            
            Queue<int> queue  = new Queue<int>();
            queue.Enqueue(1);
            queue.Enqueue(3);
            queue.Enqueue(5);

            
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 
            Console.WriteLine(queue.Dequeue()); 

            
            bool empty = queue.Count == 0;
            Console.WriteLine(empty); 

            
            
            try
            {
                queue.Dequeue();
            }
            catch (InvalidOperationException exception)
            {
                Console.WriteLine(exception.Message); 
            }
        }
    }
}








Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage


C++: #include <queue>
#include <cassert> 

int main()
{
  std::queue<int> q;
  assert( q.empty() );        

  q.push(1);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(2);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.push(3);                  
  assert( !q.empty() );       
  assert( q.front() == 1 );   

  q.pop();                    
  assert( !q.empty() );       
  assert( q.front() == 2);    

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 3);

  q.push(4);
  assert( !q.empty() );
  assert( q.front() == 3);

  q.pop();
  assert( !q.empty() );
  assert( q.front() == 4);

  q.pop();
  assert( q.empty() );

  q.push(5);
  assert( !q.empty() );
  assert( q.front() == 5);

  q.pop();
  assert( q.empty() );
}









Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage

C: #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
 
#include <sys/queue.h>



int main()
{
  int i;
  FIFOList head;

  TAILQ_INIT(&head);

  
  for(i=0; i < 20; i++) {
    m_enqueue(i, &head);
  }

  
  while( m_dequeue(&i, &head) )
    printf("%d\n", i);

  fprintf(stderr, "FIFO list %s\n",
      ( m_dequeue(&i, &head) ) ? 
      "had still an element" :
      "is void!");

  exit(0);
}










Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage





Java: import java.util.LinkedList;
import java.util.Queue;
...
Queue<Integer> queue = new LinkedList<Integer>();
System.out.println(queue.isEmpty());      

queue.add(1);
queue.add(2);
queue.add(3);
System.out.println(queue);                
System.out.println(queue.remove());       
System.out.println(queue);                
System.out.println(queue.isEmpty());      






Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage







Python: let my_queue = Queue()

my_queue.push!('foo')
my_queue.push!('bar')
my_queue.push!('baz')

print my_queue.pop!() 
print my_queue.pop!() 
print my_queue.pop!() 




Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage








VB: Public Sub fifo()
    push "One"
    push "Two"
    push "Three"
    Debug.Print pop, pop, pop, empty_
End Sub



Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage






PHP: <?php
$queue = new SplQueue;
echo $queue->isEmpty() ? 'true' : 'false', "\n";  // empty test - returns true

$queue->enqueue(1);
$queue->enqueue(2);
$queue->enqueue(3);
echo $queue->dequeue(), "\n";                     // returns 1
echo $queue->isEmpty() ? 'true' : 'false', "\n";  // returns false
?>





Fortran: module fifo_nodes
  type fifo_node
     integer :: datum
     
     type(fifo_node), pointer :: next
     logical :: valid
  end type fifo_node
end module fifo_nodes

program FIFOTest
  use fifo
  implicit none

  type(fifo_head) :: thehead
  type(fifo_node), dimension(5) :: ex, xe
  integer :: i
  
  call new_fifo(thehead)

  do i = 1, 5
     ex(i)%datum = i
     call fifo_enqueue(thehead, ex(i))
  end do

  i = 1
  do
     call fifo_dequeue(thehead, xe(i))
     print *, xe(i)%datum
     i = i + 1
     if ( fifo_isempty(thehead) ) exit
  end do

end program FIFOTest
Task: Queue_Usage






PHP: <?php
$queue = new SplQueue;
echo $queue->isEmpty() ? 'true' : 'false', "\n";  // empty test - returns true

$queue->enqueue(1);
$queue->enqueue(2);
$queue->enqueue(3);
echo $queue->dequeue(), "\n";                     // returns 1
echo $queue->isEmpty() ? 'true' : 'false', "\n";  // returns false
?>