WeixiangYan/CodeTransOcean huggingface dataset:
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}










Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical




Go: package main

import "github.com/mattn/go-gtk/gtk"

func main() {
   gtk.Init(nil)
   win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
   win.SetTitle("Goodbye, World!")
   win.SetSizeRequest(300, 200)
   win.Connect("destroy", gtk.MainQuit)
   button := gtk.NewButtonWithLabel("Goodbye, World!")
   win.Add(button)
   button.Connect("clicked", gtk.MainQuit)
   win.ShowAll()
   gtk.Main()
}








Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}







Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical







Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'





Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical








VB: MsgBox("Goodbye, World!")




Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical

C: #include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}
Task: Hello world_Graphical



C#: using System;
using System.Windows.Forms;

class Program {
    static void Main(string[] args) {
        Application.EnableVisualStyles(); 
        MessageBox.Show("Goodbye, World!");
    }
}
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}
Task: Hello world_Graphical







Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'
Task: Hello world_Graphical




Go: package main

import "github.com/mattn/go-gtk/gtk"

func main() {
   gtk.Init(nil)
   win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
   win.SetTitle("Goodbye, World!")
   win.SetSizeRequest(300, 200)
   win.Connect("destroy", gtk.MainQuit)
   button := gtk.NewButtonWithLabel("Goodbye, World!")
   win.Add(button)
   button.Connect("clicked", gtk.MainQuit)
   win.ShowAll()
   gtk.Main()
}
Task: Hello world_Graphical








VB: MsgBox("Goodbye, World!")
Task: Hello world_Graphical



C#: using System;
using System.Windows.Forms;

class Program {
    static void Main(string[] args) {
        Application.EnableVisualStyles(); 
        MessageBox.Show("Goodbye, World!");
    }
}








Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}









Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical

C: #include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}










Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}






Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical







Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'




Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical








VB: MsgBox("Goodbye, World!")



Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();





Fortran: program hello
    use windows
    integer :: res
    res = MessageBoxA(0, LOC("Hello, World"), LOC("Window Title"), MB_OK)
end program
Task: Hello world_Graphical

C: #include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Goodbye, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}









COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical



C#: using System;
using System.Windows.Forms;

class Program {
    static void Main(string[] args) {
        Application.EnableVisualStyles(); 
        MessageBox.Show("Goodbye, World!");
    }
}







COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical


C++: #include <gtkmm.h>
int main(int argc, char *argv[])
{
   Gtk::Main app(argc, argv);
   Gtk::MessageDialog msg("Goodbye, World!");
   msg.run();
}








COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical





Java: import javax.swing.*;
import java.awt.*;

public class OutputSwing {

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable(){
            public void run() {
                JOptionPane.showMessageDialog (null, "Goodbye, World!"); 
                JFrame frame = new JFrame("Goodbye, World!");            
                JTextArea text = new JTextArea("Goodbye, World!");       
                JButton button = new JButton("Goodbye, World!");         

                frame.setLayout(new FlowLayout());
                frame.add(button);
                frame.add(text);
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
            }
        });
    }
}





COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical







Python: import bpy


bpy.data.objects['Cube'].select_set(True)


bpy.ops.object.delete(True)
  

bpy.data.curves.new(type="FONT", name="Font Curve").body = "Hello World"
font_obj = bpy.data.objects.new(name="Font Object", object_data=bpy.data.curves["Font Curve"])
bpy.context.scene.collection.objects.link(font_obj)
        

bpy.context.scene.camera.location = (2.5,0.3,10)


bpy.context.scene.camera.rotation_euler = (0,0,0)


area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'



COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical








VB: MsgBox("Goodbye, World!")


COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical




Go: package main

import "github.com/mattn/go-gtk/gtk"

func main() {
   gtk.Init(nil)
   win := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
   win.SetTitle("Goodbye, World!")
   win.SetSizeRequest(300, 200)
   win.Connect("destroy", gtk.MainQuit)
   button := gtk.NewButtonWithLabel("Goodbye, World!")
   win.Add(button)
   button.Connect("clicked", gtk.MainQuit)
   win.ShowAll()
   gtk.Main()
}






COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();






Ada: with Gdk.Event;   use Gdk.Event;
with Gtk.Label;   use Gtk.Label;
with Gtk.Window;  use Gtk.Window;
with Gtk.Widget;  use Gtk.Widget;

with Gtk.Handlers;
with Gtk.Main;

procedure Windowed_Goodbye_World is
   Window : Gtk_Window;
   Label  : Gtk_Label;

   package Handlers is new Gtk.Handlers.Callback (Gtk_Widget_Record);
   package Return_Handlers is
      new Gtk.Handlers.Return_Callback (Gtk_Widget_Record, Boolean);

   function Delete_Event (Widget : access Gtk_Widget_Record'Class)
      return Boolean is
   begin
      return False;
   end Delete_Event;

   procedure Destroy (Widget : access Gtk_Widget_Record'Class) is
   begin
     Gtk.Main.Main_Quit;
   end Destroy;

begin
   Gtk.Main.Init;
   Gtk.Window.Gtk_New (Window);
   Gtk_New (Label, "Goodbye, World!");
   Add (Window, Label);
   Return_Handlers.Connect
   (  Window,
      "delete_event",
      Return_Handlers.To_Marshaller (Delete_Event'Access)
   );
   Handlers.Connect
   (  Window,
      "destroy",
      Handlers.To_Marshaller (Destroy'Access)
   );
   Show_All (Label);
   Show (Window);

   Gtk.Main.Main;
end Windowed_Goodbye_World;
Task: Hello world_Graphical






PHP: if (!class_exists('gtk')) 
{
    die("Please load the php-gtk2 module in your php.ini\r\n");
}

$wnd = new GtkWindow();
$wnd->set_title('Goodbye world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
 
$lblHello = new GtkLabel("Goodbye, World!");
$wnd->add($lblHello);
 
$wnd->show_all();
Gtk::main();




COBOL:        CLASS-ID ProgramClass.
       METHOD-ID Main STATIC.
       PROCEDURE DIVISION.
           INVOKE TYPE Application::EnableVisualStyles() 
           INVOKE TYPE MessageBox::Show("Goodbye, World!")
       END METHOD.
       END CLASS.
Task: Search a list



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

class Program {
    static void Main(string[] args) {
        List<string> haystack = new List<string>() { "Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Bozo" };

        foreach (string needle in new string[] { "Washington", "Bush" }) {
            int index = haystack.IndexOf(needle);
            
            if (index < 0) Console.WriteLine("{0} is not in haystack",needle);                
            else Console.WriteLine("{0} {1}",index,needle);
        }
    }
}









Ada: with Ada.Strings.Unbounded;  use Ada.Strings.Unbounded;
with Ada.Text_IO;            use Ada.Text_IO;

procedure Test_List_Index is
   Not_In : exception;
   
   type List is array (Positive range <>) of Unbounded_String;
   
   function Index (Haystack : List; Needle : String) return Positive is
   begin
      for Index in Haystack'Range loop
         if Haystack (Index) = Needle then
            return Index;
         end if;
      end loop;
      raise Not_In;
   end Index;

      
   function "+" (X, Y : String) return List is
   begin
      return (1 => To_Unbounded_String (X), 2 => To_Unbounded_String (Y));
   end "+";
   
   function "+" (X : List; Y : String) return List is
   begin
      return X & (1 => To_Unbounded_String (Y));
   end "+";
   
   Haystack : List := "Zig"+"Zag"+"Wally"+"Ronald"+"Bush"+"Krusty"+"Charlie"+"Bush"+"Bozo";

   procedure Check (Needle : String) is
   begin
      Put (Needle);
      Put_Line ("at" & Positive'Image (Index (Haystack, Needle)));
   exception
      when Not_In => Put_Line (" is not in");
   end Check;
begin
   Check ("Washington");
   Check ("Bush");
end Test_List_Index;