WeixiangYan/CodeTransOcean huggingface dataset:
Task: Old lady swallowed a fly




Go: package main

import "fmt"

var name, lyric, animals = 0, 1, [][]string{
	{"fly", "I don't know why she swallowed a fly. Perhaps she'll die."},
	{"spider", "That wiggled and jiggled and tickled inside her."},
	{"bird", "How absurd, to swallow a bird."},
	{"cat", "Imagine that, she swallowed a cat."},
	{"dog", "What a hog, to swallow a dog."},
	{"goat", "She just opened her throat and swallowed that goat."},
	{"cow", "I don't know how she swallowed that cow."},
	{"horse", "She's dead, of course."},
}

func main() {
	for i, animal := range animals {
		fmt.Printf("There was an old lady who swallowed a %s,\n",
			animal[name])

		if i > 0 {
			fmt.Println(animal[lyric])
		}

		
		
		if i+1 == len(animals) {
			break
		}

		for ; i > 0; i-- {
			fmt.Printf("She swallowed the %s to catch the %s,\n",
				animals[i][name], animals[i-1][name])
		}

		fmt.Println(animals[0][lyric] + "\n")
	}
}








Ada: with Ada.Text_IO, Ada.Containers.Indefinite_Doubly_Linked_Lists; use Ada.Text_IO;

procedure Swallow_Fly is

   package Strings is new Ada.Containers.Indefinite_Doubly_Linked_Lists(String);

   Lines, Animals: Strings.List;

   procedure Swallow(Animal: String;
                     Second_Line: String;
                     Permanent_Second_Line: Boolean := True) is

      procedure Print(C: Strings.Cursor) is
      begin
         Put_Line(Strings.Element(C));
      end Print;

   begin
      Put_Line("There was an old lady who swallowed a " & Animal & ",");
      Put_Line(Second_Line);
      if not Animals.Is_Empty then
         Lines.Prepend("She swallowed the " & Animal & " to catch the " &
			 Animals.Last_Element & ",");
      end if;
      Lines.Iterate(Print'Access);
      New_Line;
      if Permanent_Second_Line then
         Lines.Prepend(Second_Line);
      end if;
      Animals.Append(Animal); 
   end Swallow;

   procedure Swallow_TSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &", to swallow a " & Animal & ";", False);
   end Swallow_TSA;

   procedure Swallow_SSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &" she swallowed a " & Animal & ";", False);
   end Swallow_SSA;

begin
   Lines.Append("Perhaps she'll die!");

   Swallow("fly", "But I don't know why she swallowed the fly,");
   Swallow("spider",  "That wriggled and jiggled and tickled inside her;");
   Swallow_TSA("bird", "Quite absurd");
   Swallow_TSA("cat", "Fancy that");
   Swallow_TSA("dog", "What a hog");
   Swallow_TSA("pig", "Her mouth was so big");
   Swallow_TSA("goat","She just opened her throat");
   Swallow_SSA("cow", "I don't know how");
   Swallow_TSA("donkey", "It was rather wonky");

   Put_Line("There was an old lady who swallowed a horse ...");
   Put_Line("She's dead, of course!");
end Swallow_Fly;
Task: Old lady swallowed a fly





Java: public class OldLadySwallowedAFly {

    final static String[] data = {
        "_ha _c _e _p,/Quite absurd_f_p;_`cat,/Fancy that_fcat;_j`dog,/What a hog"
        + "_fdog;_l`pig,/Her mouth_qso big_fpig;_d_r,/She just opened her throat_f_"
        + "r;_icow,/_mhow she_ga cow;_k_o,/It_qrather wonky_f_o;_a_o_bcow,_khorse.."
        + "./She's dead, of course!/", "_a_p_b_e ", "/S_t ", " to catch the ", "fly,/Bu"
        + "t _mwhy s_t fly,/Perhaps she'll die!
        + "t wr_nj_ntickled inside her;_aspider_b_c", ", to_s a ", "_sed ", "There_qan"
        + " old lady who_g", "_a_r_bpig,_d", "_acat_b_p,_", "_acow_b_r,_i", "_adog_bcat"
        + ",_j", "I don't know ", "iggled and ", "donkey", "bird", " was ", "goat", " swal"
        + "low", "he_gthe"};

    static boolean oldLady(String part, boolean s) {
        for (char c : part.toCharArray()) {
            if (s)
                s = oldLady(data[c - '_'], false);
            else if (c == '_')
                s = true;
            else
                System.out.print(c == '/' ? '\n' : c);
        }
        return s;
    }

    public static void main(String[] args) {
        oldLady(data[0], false);
    }
}







Ada: with Ada.Text_IO, Ada.Containers.Indefinite_Doubly_Linked_Lists; use Ada.Text_IO;

procedure Swallow_Fly is

   package Strings is new Ada.Containers.Indefinite_Doubly_Linked_Lists(String);

   Lines, Animals: Strings.List;

   procedure Swallow(Animal: String;
                     Second_Line: String;
                     Permanent_Second_Line: Boolean := True) is

      procedure Print(C: Strings.Cursor) is
      begin
         Put_Line(Strings.Element(C));
      end Print;

   begin
      Put_Line("There was an old lady who swallowed a " & Animal & ",");
      Put_Line(Second_Line);
      if not Animals.Is_Empty then
         Lines.Prepend("She swallowed the " & Animal & " to catch the " &
			 Animals.Last_Element & ",");
      end if;
      Lines.Iterate(Print'Access);
      New_Line;
      if Permanent_Second_Line then
         Lines.Prepend(Second_Line);
      end if;
      Animals.Append(Animal); 
   end Swallow;

   procedure Swallow_TSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &", to swallow a " & Animal & ";", False);
   end Swallow_TSA;

   procedure Swallow_SSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &" she swallowed a " & Animal & ";", False);
   end Swallow_SSA;

begin
   Lines.Append("Perhaps she'll die!");

   Swallow("fly", "But I don't know why she swallowed the fly,");
   Swallow("spider",  "That wriggled and jiggled and tickled inside her;");
   Swallow_TSA("bird", "Quite absurd");
   Swallow_TSA("cat", "Fancy that");
   Swallow_TSA("dog", "What a hog");
   Swallow_TSA("pig", "Her mouth was so big");
   Swallow_TSA("goat","She just opened her throat");
   Swallow_SSA("cow", "I don't know how");
   Swallow_TSA("donkey", "It was rather wonky");

   Put_Line("There was an old lady who swallowed a horse ...");
   Put_Line("She's dead, of course!");
end Swallow_Fly;
Task: Old lady swallowed a fly







Python: import zlib, base64

b64 = b
print(zlib.decompress(base64.b64decode(b64)).decode("utf-8", "strict"))





Ada: with Ada.Text_IO, Ada.Containers.Indefinite_Doubly_Linked_Lists; use Ada.Text_IO;

procedure Swallow_Fly is

   package Strings is new Ada.Containers.Indefinite_Doubly_Linked_Lists(String);

   Lines, Animals: Strings.List;

   procedure Swallow(Animal: String;
                     Second_Line: String;
                     Permanent_Second_Line: Boolean := True) is

      procedure Print(C: Strings.Cursor) is
      begin
         Put_Line(Strings.Element(C));
      end Print;

   begin
      Put_Line("There was an old lady who swallowed a " & Animal & ",");
      Put_Line(Second_Line);
      if not Animals.Is_Empty then
         Lines.Prepend("She swallowed the " & Animal & " to catch the " &
			 Animals.Last_Element & ",");
      end if;
      Lines.Iterate(Print'Access);
      New_Line;
      if Permanent_Second_Line then
         Lines.Prepend(Second_Line);
      end if;
      Animals.Append(Animal); 
   end Swallow;

   procedure Swallow_TSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &", to swallow a " & Animal & ";", False);
   end Swallow_TSA;

   procedure Swallow_SSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &" she swallowed a " & Animal & ";", False);
   end Swallow_SSA;

begin
   Lines.Append("Perhaps she'll die!");

   Swallow("fly", "But I don't know why she swallowed the fly,");
   Swallow("spider",  "That wriggled and jiggled and tickled inside her;");
   Swallow_TSA("bird", "Quite absurd");
   Swallow_TSA("cat", "Fancy that");
   Swallow_TSA("dog", "What a hog");
   Swallow_TSA("pig", "Her mouth was so big");
   Swallow_TSA("goat","She just opened her throat");
   Swallow_SSA("cow", "I don't know how");
   Swallow_TSA("donkey", "It was rather wonky");

   Put_Line("There was an old lady who swallowed a horse ...");
   Put_Line("She's dead, of course!");
end Swallow_Fly;
Task: Old lady swallowed a fly








VB: a=array( _
array("fly",""),_ 
array("spider","That wiggled and jiggled and tickled inside her"), _
array("bird","How absurd, to swallow a bird"), _
array("cat","Imagine that. She swallowed a cat"), _
array("dog","What a hog to swallow a dog"), _
array("goat","She just opened her throat and swallowed that goat"),_ 
array("cow","I don
array("horse","She
)

b1="I don
b2="There was an old lady who swallowed a @ani@."
b3="She swallowed the @ani@ to catch the @pani@."

sub print(s): wscript.stdout.write(s) & vbcrlf : end sub 

for i=0 to ubound(a)
     ani=a(i)(0)
     print replace(b2,"@ani@",ani)
     print a(i)(1)
     if i=ubound(a) then exit for  
   for j= i-1 to 0 step -1
      oldani=ani
      ani=a(j)(0)
      print replace(replace(b3,"@ani@",oldani),"@pani@",ani)
      if j=1 then print a(1)(1) 
   next 
   print b1
next




Ada: with Ada.Text_IO, Ada.Containers.Indefinite_Doubly_Linked_Lists; use Ada.Text_IO;

procedure Swallow_Fly is

   package Strings is new Ada.Containers.Indefinite_Doubly_Linked_Lists(String);

   Lines, Animals: Strings.List;

   procedure Swallow(Animal: String;
                     Second_Line: String;
                     Permanent_Second_Line: Boolean := True) is

      procedure Print(C: Strings.Cursor) is
      begin
         Put_Line(Strings.Element(C));
      end Print;

   begin
      Put_Line("There was an old lady who swallowed a " & Animal & ",");
      Put_Line(Second_Line);
      if not Animals.Is_Empty then
         Lines.Prepend("She swallowed the " & Animal & " to catch the " &
			 Animals.Last_Element & ",");
      end if;
      Lines.Iterate(Print'Access);
      New_Line;
      if Permanent_Second_Line then
         Lines.Prepend(Second_Line);
      end if;
      Animals.Append(Animal); 
   end Swallow;

   procedure Swallow_TSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &", to swallow a " & Animal & ";", False);
   end Swallow_TSA;

   procedure Swallow_SSA(Animal: String; Part_Of_Line_2: String) is
   begin
      Swallow(Animal, Part_Of_Line_2 &" she swallowed a " & Animal & ";", False);
   end Swallow_SSA;

begin
   Lines.Append("Perhaps she'll die!");

   Swallow("fly", "But I don't know why she swallowed the fly,");
   Swallow("spider",  "That wriggled and jiggled and tickled inside her;");
   Swallow_TSA("bird", "Quite absurd");
   Swallow_TSA("cat", "Fancy that");
   Swallow_TSA("dog", "What a hog");
   Swallow_TSA("pig", "Her mouth was so big");
   Swallow_TSA("goat","She just opened her throat");
   Swallow_SSA("cow", "I don't know how");
   Swallow_TSA("donkey", "It was rather wonky");

   Put_Line("There was an old lady who swallowed a horse ...");
   Put_Line("She's dead, of course!");
end Swallow_Fly;
Task: Old lady swallowed a fly

C: #include <stdio.h>
static char const *animals[] = {
    "fly", 
    "spider", 
    "bird", 
    "cat", 
    "dog", 
    "goat", 
    "cow", 
    "horse"
};
static char const *verses[]  = {
    "I don't know why she swallowed that fly.\nPerhaps she'll die\n",
    "That wiggled and jiggled and tickled inside her",
    "How absurd, to swallow a bird",
    "Imagine that. She swallowed a cat",
    "What a hog to swallow a dog",
    "She just opened her throat and swallowed that goat",
    "I don't know how she swallowed that cow",
    "She's dead of course"
};

#define LEN(ARR) (sizeof ARR / sizeof *ARR)

int main(void)
{
    for (size_t i = 0; i < LEN(animals); i++) {
        printf("There was an old lady who swallowed a %s\n%s\n", animals[i], verses[i]);
        for (size_t j = i; j > 0 && i < LEN(animals) - 1; j--) {
            printf("She swallowed the %s to catch the %s\n", animals[j], animals[j-1]);
            if (j == 1) {
                printf("%s\n", verses[0]);
            }
        }
    }
}
Task: Old lady swallowed a fly



C#: using System;

namespace OldLady
{
    internal class Program
    {
        private const string reason = "She swallowed the {0} to catch the {1}";
        private static readonly string[] creatures = {"fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"};

        private static readonly string[] comments =
        {
            "I don't know why she swallowed that fly.\nPerhaps she'll die\n",
            "That wiggled and jiggled and tickled inside her",
            "How absurd, to swallow a bird",
            "Imagine that. She swallowed a cat",
            "What a hog to swallow a dog",
            "She just opened her throat and swallowed that goat",
            "I don't know how she swallowed that cow",
            "She's dead of course"
        };

        private static void Main()
        {
            int max = creatures.Length;
            for (int i = 0; i < max; i++)
            {
                Console.WriteLine("There was an old lady who swallowed a {0}", creatures[i]);
                Console.WriteLine(comments[i]);
                for (int j = i; j > 0 && i < max - 1; j--)
                {
                    Console.WriteLine(reason, creatures[j], creatures[j - 1]);
                    if (j == 1)
                    {
                        Console.WriteLine(comments[j - 1]);
                    }
                }
            }
            Console.Read();
        }
    }
}
Task: Old lady swallowed a fly


C++: #include <iostream>

const char *CREATURES[] = { "fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse" };
const char *COMMENTS[] = {
    "I don't know why she swallowed that fly.\nPerhaps she'll die\n",
    "That wiggled and jiggled and tickled inside her",
    "How absurd, to swallow a bird",
    "Imagine that. She swallowed a cat",
    "What a hog to swallow a dog",
    "She just opened her throat and swallowed that goat",
    "I don't know how she swallowed that cow",
    "She's dead of course"
};

int main() {
    auto max = sizeof(CREATURES) / sizeof(char*);
    for (size_t i = 0; i < max; ++i) {
        std::cout << "There was an old lady who swallowed a " << CREATURES[i] << '\n';
        std::cout << COMMENTS[i] << '\n';
        for (int j = i; j > 0 && i < max - 1; --j) {
            std::cout << "She swallowed the " << CREATURES[j] << " to catch the " << CREATURES[j - 1] << '\n';
            if (j == 1)
                std::cout << COMMENTS[j - 1] << '\n';
        }
    }

    return 0;
}
Task: Old lady swallowed a fly





Java: public class OldLadySwallowedAFly {

    final static String[] data = {
        "_ha _c _e _p,/Quite absurd_f_p;_`cat,/Fancy that_fcat;_j`dog,/What a hog"
        + "_fdog;_l`pig,/Her mouth_qso big_fpig;_d_r,/She just opened her throat_f_"
        + "r;_icow,/_mhow she_ga cow;_k_o,/It_qrather wonky_f_o;_a_o_bcow,_khorse.."
        + "./She's dead, of course!/", "_a_p_b_e ", "/S_t ", " to catch the ", "fly,/Bu"
        + "t _mwhy s_t fly,/Perhaps she'll die!
        + "t wr_nj_ntickled inside her;_aspider_b_c", ", to_s a ", "_sed ", "There_qan"
        + " old lady who_g", "_a_r_bpig,_d", "_acat_b_p,_", "_acow_b_r,_i", "_adog_bcat"
        + ",_j", "I don't know ", "iggled and ", "donkey", "bird", " was ", "goat", " swal"
        + "low", "he_gthe"};

    static boolean oldLady(String part, boolean s) {
        for (char c : part.toCharArray()) {
            if (s)
                s = oldLady(data[c - '_'], false);
            else if (c == '_')
                s = true;
            else
                System.out.print(c == '/' ? '\n' : c);
        }
        return s;
    }

    public static void main(String[] args) {
        oldLady(data[0], false);
    }
}
Task: Old lady swallowed a fly







Python: import zlib, base64

b64 = b
print(zlib.decompress(base64.b64decode(b64)).decode("utf-8", "strict"))
Task: Old lady swallowed a fly








VB: a=array( _
array("fly",""),_ 
array("spider","That wiggled and jiggled and tickled inside her"), _
array("bird","How absurd, to swallow a bird"), _
array("cat","Imagine that. She swallowed a cat"), _
array("dog","What a hog to swallow a dog"), _
array("goat","She just opened her throat and swallowed that goat"),_ 
array("cow","I don
array("horse","She
)

b1="I don
b2="There was an old lady who swallowed a @ani@."
b3="She swallowed the @ani@ to catch the @pani@."

sub print(s): wscript.stdout.write(s) & vbcrlf : end sub 

for i=0 to ubound(a)
     ani=a(i)(0)
     print replace(b2,"@ani@",ani)
     print a(i)(1)
     if i=ubound(a) then exit for  
   for j= i-1 to 0 step -1
      oldani=ani
      ani=a(j)(0)
      print replace(replace(b3,"@ani@",oldani),"@pani@",ani)
      if j=1 then print a(1)(1) 
   next 
   print b1
next
Task: Old lady swallowed a fly




Go: package main

import "fmt"

var name, lyric, animals = 0, 1, [][]string{
	{"fly", "I don't know why she swallowed a fly. Perhaps she'll die."},
	{"spider", "That wiggled and jiggled and tickled inside her."},
	{"bird", "How absurd, to swallow a bird."},
	{"cat", "Imagine that, she swallowed a cat."},
	{"dog", "What a hog, to swallow a dog."},
	{"goat", "She just opened her throat and swallowed that goat."},
	{"cow", "I don't know how she swallowed that cow."},
	{"horse", "She's dead, of course."},
}

func main() {
	for i, animal := range animals {
		fmt.Printf("There was an old lady who swallowed a %s,\n",
			animal[name])

		if i > 0 {
			fmt.Println(animal[lyric])
		}

		
		
		if i+1 == len(animals) {
			break
		}

		for ; i > 0; i-- {
			fmt.Printf("She swallowed the %s to catch the %s,\n",
				animals[i][name], animals[i-1][name])
		}

		fmt.Println(animals[0][lyric] + "\n")
	}
}
Task: Old lady swallowed a fly



C#: using System;

namespace OldLady
{
    internal class Program
    {
        private const string reason = "She swallowed the {0} to catch the {1}";
        private static readonly string[] creatures = {"fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse"};

        private static readonly string[] comments =
        {
            "I don't know why she swallowed that fly.\nPerhaps she'll die\n",
            "That wiggled and jiggled and tickled inside her",
            "How absurd, to swallow a bird",
            "Imagine that. She swallowed a cat",
            "What a hog to swallow a dog",
            "She just opened her throat and swallowed that goat",
            "I don't know how she swallowed that cow",
            "She's dead of course"
        };

        private static void Main()
        {
            int max = creatures.Length;
            for (int i = 0; i < max; i++)
            {
                Console.WriteLine("There was an old lady who swallowed a {0}", creatures[i]);
                Console.WriteLine(comments[i]);
                for (int j = i; j > 0 && i < max - 1; j--)
                {
                    Console.WriteLine(reason, creatures[j], creatures[j - 1]);
                    if (j == 1)
                    {
                        Console.WriteLine(comments[j - 1]);
                    }
                }
            }
            Console.Read();
        }
    }
}








Fortran: program fly
  
  implicit none

  character(len=52), dimension(0:8,2) :: line
  integer :: i,j
  
  line(1,1) = 'fly'
  line(2,1) = 'spider'
  line(3,1) = 'bird'
  line(4,1) = 'cat'
  line(5,1) = 'dog'
  line(6,1) = 'goat'
  line(7,1) = 'cow'
  line(8,1) = 'horse'
  line(0,2) = "Perhaps she'll die."
  line(1,2) = "I don't know why she swallowed that fly."
  line(2,2) = "That wiggled and jiggled and tickled inside her." 
  line(3,2) = "How absurd to swallow a bird."                      
  line(4,2) = "Imagine that. She swallowed a cat."                  
  line(5,2) = "What a hog to swallow a dog."                        
  line(6,2) = "She just opened her throat and swallowed that goat." 
  line(7,2) = "I don't know how she swallowed that cow."            
  line(8,2) = "She's dead of course."                                  

  
  verses:do i = 1,8
     write(*,*) 'There was an old lady who swallowed a '//trim(line(i,1))//"."
     write(*,*) trim(line(i,2))
     
     swallowed:do j = i,2,-1
        write(*,*) "She swallowed the "//trim(line(j,1))//" to catch the "//trim(line(j-1,1))//","
     end do swallowed
     write(*,*)  trim(line(0,2))
     write(*,*)
  end do verses
     
end program fly
Task: Old lady swallowed a fly


C++: #include <iostream>

const char *CREATURES[] = { "fly", "spider", "bird", "cat", "dog", "goat", "cow", "horse" };
const char *COMMENTS[] = {
    "I don't know why she swallowed that fly.\nPerhaps she'll die\n",
    "That wiggled and jiggled and tickled inside her",
    "How absurd, to swallow a bird",
    "Imagine that. She swallowed a cat",
    "What a hog to swallow a dog",
    "She just opened her throat and swallowed that goat",
    "I don't know how she swallowed that cow",
    "She's dead of course"
};

int main() {
    auto max = sizeof(CREATURES) / sizeof(char*);
    for (size_t i = 0; i < max; ++i) {
        std::cout << "There was an old lady who swallowed a " << CREATURES[i] << '\n';
        std::cout << COMMENTS[i] << '\n';
        for (int j = i; j > 0 && i < max - 1; --j) {
            std::cout << "She swallowed the " << CREATURES[j] << " to catch the " << CREATURES[j - 1] << '\n';
            if (j == 1)
                std::cout << COMMENTS[j - 1] << '\n';
        }
    }

    return 0;
}









Fortran: program fly
  
  implicit none

  character(len=52), dimension(0:8,2) :: line
  integer :: i,j
  
  line(1,1) = 'fly'
  line(2,1) = 'spider'
  line(3,1) = 'bird'
  line(4,1) = 'cat'
  line(5,1) = 'dog'
  line(6,1) = 'goat'
  line(7,1) = 'cow'
  line(8,1) = 'horse'
  line(0,2) = "Perhaps she'll die."
  line(1,2) = "I don't know why she swallowed that fly."
  line(2,2) = "That wiggled and jiggled and tickled inside her." 
  line(3,2) = "How absurd to swallow a bird."                      
  line(4,2) = "Imagine that. She swallowed a cat."                  
  line(5,2) = "What a hog to swallow a dog."                        
  line(6,2) = "She just opened her throat and swallowed that goat." 
  line(7,2) = "I don't know how she swallowed that cow."            
  line(8,2) = "She's dead of course."                                  

  
  verses:do i = 1,8
     write(*,*) 'There was an old lady who swallowed a '//trim(line(i,1))//"."
     write(*,*) trim(line(i,2))
     
     swallowed:do j = i,2,-1
        write(*,*) "She swallowed the "//trim(line(j,1))//" to catch the "//trim(line(j-1,1))//","
     end do swallowed
     write(*,*)  trim(line(0,2))
     write(*,*)
  end do verses
     
end program fly