WeixiangYan/CodeTransOcean huggingface dataset:
Task: Variadic function





Java: module VariadicFunction
    {
    void show(String[] strings)
        {
        @Inject Console console;
        strings.forEach(s -> console.print(s));
        }

    void run()
        {
        show(["hello", "world"]);

        String s1 = "not";
        String s2 = "a";
        String s3 = "constant";
        String s4 = "literal";
        show([s1, s2, s3, s4]);
        }
    }






Fortran: program varargs

  integer, dimension(:), allocatable :: va
  integer :: i

  
  call v_func()
  call v_func( (/ 100 /) )
  call v_func( (/ 90, 20, 30 /) )

  
  allocate(va(5))
  va = (/ (i,i=1,5) /)
  call v_func(va)
  deallocate(va)

contains

  subroutine v_func(arglist)
    integer, dimension(:), intent(in), optional :: arglist

    integer :: i

    if ( present(arglist) ) then
       do i = lbound(arglist, 1), ubound(arglist, 1)
          print *, arglist(i)
       end do
    else
       print *, "no argument at all"
    end if
  end subroutine v_func

end program varargs
Task: Variadic function







Python: def print_all(*things):
    for x in things:
        print x




Fortran: program varargs

  integer, dimension(:), allocatable :: va
  integer :: i

  
  call v_func()
  call v_func( (/ 100 /) )
  call v_func( (/ 90, 20, 30 /) )

  
  allocate(va(5))
  va = (/ (i,i=1,5) /)
  call v_func(va)
  deallocate(va)

contains

  subroutine v_func(arglist)
    integer, dimension(:), intent(in), optional :: arglist

    integer :: i

    if ( present(arglist) ) then
       do i = lbound(arglist, 1), ubound(arglist, 1)
          print *, arglist(i)
       end do
    else
       print *, "no argument at all"
    end if
  end subroutine v_func

end program varargs
Task: Variadic function








VB: Sub PrintArgs(ParamArray Args() As String)
  For i As Integer = 0 To Ubound(Args)
    Print(Args(i))
  Next
End Sub



Fortran: program varargs

  integer, dimension(:), allocatable :: va
  integer :: i

  
  call v_func()
  call v_func( (/ 100 /) )
  call v_func( (/ 90, 20, 30 /) )

  
  allocate(va(5))
  va = (/ (i,i=1,5) /)
  call v_func(va)
  deallocate(va)

contains

  subroutine v_func(arglist)
    integer, dimension(:), intent(in), optional :: arglist

    integer :: i

    if ( present(arglist) ) then
       do i = lbound(arglist, 1), ubound(arglist, 1)
          print *, arglist(i)
       end do
    else
       print *, "no argument at all"
    end if
  end subroutine v_func

end program varargs
Task: Variadic function






PHP: <?php
function printAll() {
  foreach (func_get_args() as $x) // first way
    echo "$x\n";

  $numargs = func_num_args(); // second way
  for ($i = 0; $i < $numargs; $i++)
    echo func_get_arg($i), "\n";
}
printAll(4, 3, 5, 6, 4, 3);
printAll(4, 3, 5);
printAll("Rosetta", "Code", "Is", "Awesome!");
?>





Fortran: program varargs

  integer, dimension(:), allocatable :: va
  integer :: i

  
  call v_func()
  call v_func( (/ 100 /) )
  call v_func( (/ 90, 20, 30 /) )

  
  allocate(va(5))
  va = (/ (i,i=1,5) /)
  call v_func(va)
  deallocate(va)

contains

  subroutine v_func(arglist)
    integer, dimension(:), intent(in), optional :: arglist

    integer :: i

    if ( present(arglist) ) then
       do i = lbound(arglist, 1), ubound(arglist, 1)
          print *, arglist(i)
       end do
    else
       print *, "no argument at all"
    end if
  end subroutine v_func

end program varargs
Task: Variadic function






PHP: <?php
function printAll() {
  foreach (func_get_args() as $x) // first way
    echo "$x\n";

  $numargs = func_num_args(); // second way
  for ($i = 0; $i < $numargs; $i++)
    echo func_get_arg($i), "\n";
}
printAll(4, 3, 5, 6, 4, 3);
printAll(4, 3, 5);
printAll("Rosetta", "Code", "Is", "Awesome!");
?>
Task: Variadic function






PHP: <?php
function printAll() {
  foreach (func_get_args() as $x) // first way
    echo "$x\n";

  $numargs = func_num_args(); // second way
  for ($i = 0; $i < $numargs; $i++)
    echo func_get_arg($i), "\n";
}
printAll(4, 3, 5, 6, 4, 3);
printAll(4, 3, 5);
printAll("Rosetta", "Code", "Is", "Awesome!");
?>






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

procedure Variadic is

   subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
   use type U_String;

   function "+"(S: String) return U_String
     renames Ada.Strings.Unbounded.To_Unbounded_String;

   function "-"(U: U_String) return String
     renames Ada.Strings.Unbounded.To_String;

   type Variadic_Array is array(Positive range <>) of U_String;

   procedure Print_Line(Params: Variadic_Array) is
   begin
      for I in Params'Range loop
         Ada.Text_IO.Put(-Params(I));
         if I < Params'Last then
            Ada.Text_IO.Put(" ");
         end if;
      end loop;
      Ada.Text_IO.New_Line;
   end Print_Line;

begin
   Print_Line((+"Mary", +"had", +"a", +"little", +"lamb.")); 
   Print_Line((1 => +"Rosetta Code is cooool!")); 
end;
Task: Write language name in 3D ASCII

C: #include <stdio.h>
const char*s = "  _____\n /____/\\\n/  ___\\/\n\\  \\/__/\n \\____/";
int main(){ puts(s); return 0; }











Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure AsciiArt is
   art : constant array(1..27) of String(1..14) :=
     (1=>"    /\\\\\\   ", 2=>"          /\\\",
      3|6|9=>"              ", 4|12=>"  /\\\\\\\\\\ ",
      5|8|11=>"         \/\\\", 7|17|21=>" /\\\//////\\\",
      10|19|20|22=>"\/\\\    \/\\\", 13|23|24=>"\/\\\\\\\\\\\\",
      14|18=>"  /\\\\\\\\\\\", 15=>" \/////////\\\",
      16=>"\/\\\//////\\\", 25=>"\///     \/// ",
      26|27=>"\//////////// ");
begin
   for i in art'Range loop
      Put(art(i)&' ');
      if i mod 3 = 0 then New_Line; Put(i/3*' '); end if;
   end loop;
end AsciiArt;
Task: Write language name in 3D ASCII


C++: #include <windows.h>
#include <iostream>


using namespace std;


int main(int argc, char* argv[])
{
	cout << 
		"                        ______          ______  " << endl <<
		"        _____     _____|\\     \\   _____|\\     \\ " << endl <<
		"   _____\\    \\_  /     / |     | /     / |     |" << endl <<
		"  /     /|     ||      |/     /||      |/     /|" << endl <<
		" /     / /____/||      |\\____/ ||      |\\____/ |" << endl <<
		"|     | |____|/ |\\     \\    | / |\\     \\    | / " << endl <<
		"|     |  _____  | \\     \\___|/  | \\     \\___|/  " << endl <<
		"|\\     \\|\\    \\ |  \\     \\      |  \\     \\      " << endl <<
		"| \\_____\\|    |  \\  \\_____\\      \\  \\_____\\     " << endl <<
		"| |     /____/|   \\ |     |       \\ |     |     " << endl <<
		" \\|_____|    ||    \\|_____|        \\|_____|     " << endl <<
		"        |____|/                                 ";

	cout << endl << endl << endl;

	system( "pause" );
	return 0;
}











Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure AsciiArt is
   art : constant array(1..27) of String(1..14) :=
     (1=>"    /\\\\\\   ", 2=>"          /\\\",
      3|6|9=>"              ", 4|12=>"  /\\\\\\\\\\ ",
      5|8|11=>"         \/\\\", 7|17|21=>" /\\\//////\\\",
      10|19|20|22=>"\/\\\    \/\\\", 13|23|24=>"\/\\\\\\\\\\\\",
      14|18=>"  /\\\\\\\\\\\", 15=>" \/////////\\\",
      16=>"\/\\\//////\\\", 25=>"\///     \/// ",
      26|27=>"\//////////// ");
begin
   for i in art'Range loop
      Put(art(i)&' ');
      if i mod 3 = 0 then New_Line; Put(i/3*' '); end if;
   end loop;
end AsciiArt;
Task: Write language name in 3D ASCII




Go: package main

import (
    "fmt"
    "strings"
)

var lean = font{
    height:  5,
    slant:   1,
    spacing: 2,
    m: map[rune][]string{
        'G': []string{
            `  _/_/_/`,
            `_/      `,
            `_/  _/_/`,
            `_/    _/`,
            `  _/_/_/`,
        },
        'o': []string{
            `        `,
            `  _/_/  `,
            `_/    _/`,
            `_/    _/`,
            `  _/_/  `,
        },
    }}

var smallKeyboard = font{
    height:  4,
    slant:   0,
    spacing: -1,
    m: map[rune][]string{
        'G': []string{
            ` ____ `,
            `||G ||`,
            `||__||`,
            `|/__\|`,
        },
        'o': []string{
            ` ____ `,
            `||o ||`,
            `||__||`,
            `|/__\|`,
        },
    }}

type font struct {
    height  int
    slant   int
    spacing int
    m       map[rune][]string
}

func render(s string, f font) string {
    rows := make([]string, f.height)
    if f.slant != 0 {
        start := 0
        if f.slant > 0 {
            start = f.height
        }
        for i := range rows {
            rows[i] = strings.Repeat(" ", (start-i)*f.slant)
        }
    }
    if f.spacing >= 0 {
        spacing := strings.Repeat(" ", f.spacing)
        for j, c := range s {
            for i, r := range f.m[c] {
                if j > 0 {
                    r = spacing + r
                }
                rows[i] += r
            }
        }
    } else {
        overlap := -f.spacing
        for j, c := range s {
            for i, r := range f.m[c] {
                if j > 0 {
                    r = r[overlap:]
                }
                rows[i] += r
            }
        }
    }
    return strings.Join(rows, "\n")
}

func main() {
    fmt.Println(render("Go", lean))
    fmt.Println(render("Go", smallKeyboard))
}








Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure AsciiArt is
   art : constant array(1..27) of String(1..14) :=
     (1=>"    /\\\\\\   ", 2=>"          /\\\",
      3|6|9=>"              ", 4|12=>"  /\\\\\\\\\\ ",
      5|8|11=>"         \/\\\", 7|17|21=>" /\\\//////\\\",
      10|19|20|22=>"\/\\\    \/\\\", 13|23|24=>"\/\\\\\\\\\\\\",
      14|18=>"  /\\\\\\\\\\\", 15=>" \/////////\\\",
      16=>"\/\\\//////\\\", 25=>"\///     \/// ",
      26|27=>"\//////////// ");
begin
   for i in art'Range loop
      Put(art(i)&' ');
      if i mod 3 = 0 then New_Line; Put(i/3*' '); end if;
   end loop;
end AsciiArt;
Task: Write language name in 3D ASCII







Python: py = '''\
 
 
 
 
 

lines = py.replace('
        .replace('X', '   ').replace('\n', ' Y') \
        .replace('< ', '<>').split('Y')

for i, l in enumerate(lines): 
    print('  ' * (len(lines) - i) + l)





Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure AsciiArt is
   art : constant array(1..27) of String(1..14) :=
     (1=>"    /\\\\\\   ", 2=>"          /\\\",
      3|6|9=>"              ", 4|12=>"  /\\\\\\\\\\ ",
      5|8|11=>"         \/\\\", 7|17|21=>" /\\\//////\\\",
      10|19|20|22=>"\/\\\    \/\\\", 13|23|24=>"\/\\\\\\\\\\\\",
      14|18=>"  /\\\\\\\\\\\", 15=>" \/////////\\\",
      16=>"\/\\\//////\\\", 25=>"\///     \/// ",
      26|27=>"\//////////// ");
begin
   for i in art'Range loop
      Put(art(i)&' ');
      if i mod 3 = 0 then New_Line; Put(i/3*' '); end if;
   end loop;
end AsciiArt;
Task: Write language name in 3D ASCII








VB: Module Module1

    Sub Main()
        Console.WriteLine(" ___      ___ ___  ________  ___  ___  ________  ___               ________  ________  ________  ___  ________           ________   _______  _________   
|\  \    /  /|\  \|\   ____\|\  \|\  \|\   __  \|\  \             |\   __  \|\   __  \|\   ____\|\  \|\   ____\         |\   ___  \|\  ___ \|\___   ___\ 
\ \  \  /  / | \  \ \  \___|\ \  \\\  \ \  \|\  \ \  \            \ \  \|\ /\ \  \|\  \ \  \___|\ \  \ \  \___|         \ \  \\ \  \ \   __/\|___ \  \_| 
 \ \  \/  / / \ \  \ \_____  \ \  \\\  \ \   __  \ \  \            \ \   __  \ \   __  \ \_____  \ \  \ \  \             \ \  \\ \  \ \  \_|/__  \ \  \  
  \ \    / /   \ \  \|____|\  \ \  \\\  \ \  \ \  \ \  \____        \ \  \|\  \ \  \ \  \|____|\  \ \  \ \  \____       __\ \  \\ \  \ \  \_|\ \  \ \  \ 
   \ \__/ /     \ \__\____\_\  \ \_______\ \__\ \__\ \_______\       \ \_______\ \__\ \__\____\_\  \ \__\ \_______\    |\__\ \__\\ \__\ \_______\  \ \__\
    \|__|/       \|__|\_________\|_______|\|__|\|__|\|_______|        \|_______|\|__|\|__|\_________\|__|\|_______|    \|__|\|__| \|__|\|_______|   \|__|
                     \|_________|                                                        \|_________|                                                    
                                                                                                                                                         
                                                                                                                                                         
")
    End Sub

End Module




Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure AsciiArt is
   art : constant array(1..27) of String(1..14) :=
     (1=>"    /\\\\\\   ", 2=>"          /\\\",
      3|6|9=>"              ", 4|12=>"  /\\\\\\\\\\ ",
      5|8|11=>"         \/\\\", 7|17|21=>" /\\\//////\\\",
      10|19|20|22=>"\/\\\    \/\\\", 13|23|24=>"\/\\\\\\\\\\\\",
      14|18=>"  /\\\\\\\\\\\", 15=>" \/////////\\\",
      16=>"\/\\\//////\\\", 25=>"\///     \/// ",
      26|27=>"\//////////// ");
begin
   for i in art'Range loop
      Put(art(i)&' ');
      if i mod 3 = 0 then New_Line; Put(i/3*' '); end if;
   end loop;
end AsciiArt;
Task: Write language name in 3D ASCII

C: #include <stdio.h>
const char*s = "  _____\n /____/\\\n/  ___\\/\n\\  \\/__/\n \\____/";
int main(){ puts(s); return 0; }
Task: Write language name in 3D ASCII


C++: #include <windows.h>
#include <iostream>


using namespace std;


int main(int argc, char* argv[])
{
	cout << 
		"                        ______          ______  " << endl <<
		"        _____     _____|\\     \\   _____|\\     \\ " << endl <<
		"   _____\\    \\_  /     / |     | /     / |     |" << endl <<
		"  /     /|     ||      |/     /||      |/     /|" << endl <<
		" /     / /____/||      |\\____/ ||      |\\____/ |" << endl <<
		"|     | |____|/ |\\     \\    | / |\\     \\    | / " << endl <<
		"|     |  _____  | \\     \\___|/  | \\     \\___|/  " << endl <<
		"|\\     \\|\\    \\ |  \\     \\      |  \\     \\      " << endl <<
		"| \\_____\\|    |  \\  \\_____\\      \\  \\_____\\     " << endl <<
		"| |     /____/|   \\ |     |       \\ |     |     " << endl <<
		" \\|_____|    ||    \\|_____|        \\|_____|     " << endl <<
		"        |____|/                                 ";

	cout << endl << endl << endl;

	system( "pause" );
	return 0;
}
Task: Write language name in 3D ASCII







Python: py = '''\
 
 
 
 
 

lines = py.replace('
        .replace('X', '   ').replace('\n', ' Y') \
        .replace('< ', '<>').split('Y')

for i, l in enumerate(lines): 
    print('  ' * (len(lines) - i) + l)
Task: Write language name in 3D ASCII








VB: Module Module1

    Sub Main()
        Console.WriteLine(" ___      ___ ___  ________  ___  ___  ________  ___               ________  ________  ________  ___  ________           ________   _______  _________   
|\  \    /  /|\  \|\   ____\|\  \|\  \|\   __  \|\  \             |\   __  \|\   __  \|\   ____\|\  \|\   ____\         |\   ___  \|\  ___ \|\___   ___\ 
\ \  \  /  / | \  \ \  \___|\ \  \\\  \ \  \|\  \ \  \            \ \  \|\ /\ \  \|\  \ \  \___|\ \  \ \  \___|         \ \  \\ \  \ \   __/\|___ \  \_| 
 \ \  \/  / / \ \  \ \_____  \ \  \\\  \ \   __  \ \  \            \ \   __  \ \   __  \ \_____  \ \  \ \  \             \ \  \\ \  \ \  \_|/__  \ \  \  
  \ \    / /   \ \  \|____|\  \ \  \\\  \ \  \ \  \ \  \____        \ \  \|\  \ \  \ \  \|____|\  \ \  \ \  \____       __\ \  \\ \  \ \  \_|\ \  \ \  \ 
   \ \__/ /     \ \__\____\_\  \ \_______\ \__\ \__\ \_______\       \ \_______\ \__\ \__\____\_\  \ \__\ \_______\    |\__\ \__\\ \__\ \_______\  \ \__\
    \|__|/       \|__|\_________\|_______|\|__|\|__|\|_______|        \|_______|\|__|\|__|\_________\|__|\|_______|    \|__|\|__| \|__|\|_______|   \|__|
                     \|_________|                                                        \|_________|                                                    
                                                                                                                                                         
                                                                                                                                                         
")
    End Sub

End Module
Task: Write language name in 3D ASCII




Go: package main

import (
    "fmt"
    "strings"
)

var lean = font{
    height:  5,
    slant:   1,
    spacing: 2,
    m: map[rune][]string{
        'G': []string{
            `  _/_/_/`,
            `_/      `,
            `_/  _/_/`,
            `_/    _/`,
            `  _/_/_/`,
        },
        'o': []string{
            `        `,
            `  _/_/  `,
            `_/    _/`,
            `_/    _/`,
            `  _/_/  `,
        },
    }}

var smallKeyboard = font{
    height:  4,
    slant:   0,
    spacing: -1,
    m: map[rune][]string{
        'G': []string{
            ` ____ `,
            `||G ||`,
            `||__||`,
            `|/__\|`,
        },
        'o': []string{
            ` ____ `,
            `||o ||`,
            `||__||`,
            `|/__\|`,
        },
    }}

type font struct {
    height  int
    slant   int
    spacing int
    m       map[rune][]string
}

func render(s string, f font) string {
    rows := make([]string, f.height)
    if f.slant != 0 {
        start := 0
        if f.slant > 0 {
            start = f.height
        }
        for i := range rows {
            rows[i] = strings.Repeat(" ", (start-i)*f.slant)
        }
    }
    if f.spacing >= 0 {
        spacing := strings.Repeat(" ", f.spacing)
        for j, c := range s {
            for i, r := range f.m[c] {
                if j > 0 {
                    r = spacing + r
                }
                rows[i] += r
            }
        }
    } else {
        overlap := -f.spacing
        for j, c := range s {
            for i, r := range f.m[c] {
                if j > 0 {
                    r = r[overlap:]
                }
                rows[i] += r
            }
        }
    }
    return strings.Join(rows, "\n")
}

func main() {
    fmt.Println(render("Go", lean))
    fmt.Println(render("Go", smallKeyboard))
}
Task: Exponentiation operator



C#: static void Main(string[] args)
{
	Console.WriteLine("5^5 = " + Expon(5, 5));
	Console.WriteLine("5.5^5 = " + Expon(5.5, 5));
	Console.ReadLine();
}

static double Expon(int Val, int Pow) 
{
	return Math.Pow(Val, Pow);
}
static double Expon(double Val, int Pow)
{
	return Math.Pow(Val, Pow);
}









Ada: package Integer_Exponentiation is
   
   procedure Exponentiate (Argument : in     Integer;
                           Exponent : in     Natural;
                           Result   :    out Integer);
   function "**" (Left  : Integer;
                  Right : Natural) return Integer;

   
   procedure Exponentiate (Argument : in     Float;
                           Exponent : in     Integer;
                           Result   :    out Float);
   function "**" (Left  : Float;
                  Right : Integer) return Float;
end Integer_Exponentiation;
Task: Exponentiation operator

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

int ipow(int base, int exp)
{
   int pow = base;
   int v = 1;
   if (exp < 0) {
      assert (base != 0);  
      return (base*base != 1)? 0: (exp&1)? base : 1;
   }
       
   while(exp > 0 )
   {
      if (exp & 1) v *= pow;
      pow *= pow;
      exp >>= 1;
    }
   return v;
}

double dpow(double base, int exp)
{
   double v=1.0;
   double pow = (exp <0)? 1.0/base : base;
   if (exp < 0) exp = - exp;

   while(exp > 0 )
   {
      if (exp & 1) v *= pow;
      pow *= pow;
      exp >>= 1;
   }
   return v;
}

int main()
{
    printf("2^6 = %d\n", ipow(2,6));
    printf("2^-6 = %d\n", ipow(2,-6));
    printf("2.71^6 = %lf\n", dpow(2.71,6));
    printf("2.71^-6 = %lf\n", dpow(2.71,-6));
}











Ada: package Integer_Exponentiation is
   
   procedure Exponentiate (Argument : in     Integer;
                           Exponent : in     Natural;
                           Result   :    out Integer);
   function "**" (Left  : Integer;
                  Right : Natural) return Integer;

   
   procedure Exponentiate (Argument : in     Float;
                           Exponent : in     Integer;
                           Result   :    out Float);
   function "**" (Left  : Float;
                  Right : Integer) return Float;
end Integer_Exponentiation;
Task: Exponentiation operator


C++: template<typename Number>
 Number power(Number base, int exponent)
{
  int zerodir;
  Number factor;
  if (exponent < 0)
  {
    zerodir = 1;
    factor = Number(1)/base;
  }
  else
  {
    zerodir = -1;
    factor = base;
  }

  Number result(1);
  while (exponent != 0)
  {
    if (exponent % 2 != 0)
    {
      result *= factor;
      exponent += zerodir;
    }
    else
    {
      factor *= factor;
      exponent /= 2;
    }
  }
  return result;
}










Ada: package Integer_Exponentiation is
   
   procedure Exponentiate (Argument : in     Integer;
                           Exponent : in     Natural;
                           Result   :    out Integer);
   function "**" (Left  : Integer;
                  Right : Natural) return Integer;

   
   procedure Exponentiate (Argument : in     Float;
                           Exponent : in     Integer;
                           Result   :    out Float);
   function "**" (Left  : Float;
                  Right : Integer) return Float;
end Integer_Exponentiation;
Task: Exponentiation operator




Go: package main

import (
    "errors"
    "fmt"
)

func expI(b, p int) (int, error) {
    if p < 0 {
        return 0, errors.New("negative power not allowed")
    }
    r := 1
    for i := 1; i <= p; i++ {
        r *= b
    }
    return r, nil
}

func expF(b float32, p int) float32 {
    var neg bool
    if p < 0 {
        neg = true
        p = -p
    }
    r := float32(1)
    for pow := b; p > 0; pow *= pow {
        if p&1 == 1 {
            r *= pow
        }
        p >>= 1
    }
    if neg {
        r = 1 / r
    }
    return r
}

func main() {
    ti := func(b, p int) {
        fmt.Printf("%d^%d: ", b, p)
        e, err := expI(b, p)
        if err != nil {
            fmt.Println(err)
        } else {
            fmt.Println(e)
        }
    }

    fmt.Println("expI tests")
    ti(2, 10)
    ti(2, -10)
    ti(-2, 10)
    ti(-2, 11)
    ti(11, 0)

    fmt.Println("overflow undetected")
    ti(10, 10)

    tf := func(b float32, p int) {
        fmt.Printf("%g^%d: %g\n", b, p, expF(b, p))
    }

    fmt.Println("\nexpF tests:")
    tf(2, 10)
    tf(2, -10)
    tf(-2, 10)
    tf(-2, 11)
    tf(11, 0)

    fmt.Println("disallowed in expI, allowed here")
    tf(0, -1)

    fmt.Println("other interesting cases for 32 bit float type")
    tf(10, 39)
    tf(10, -39)
    tf(-10, 39)
}








Ada: package Integer_Exponentiation is
   
   procedure Exponentiate (Argument : in     Integer;
                           Exponent : in     Natural;
                           Result   :    out Integer);
   function "**" (Left  : Integer;
                  Right : Natural) return Integer;

   
   procedure Exponentiate (Argument : in     Float;
                           Exponent : in     Integer;
                           Result   :    out Float);
   function "**" (Left  : Float;
                  Right : Integer) return Float;
end Integer_Exponentiation;