WeixiangYan/CodeTransOcean huggingface dataset:
Task: Loops_Break


C++: #include <iostream>
#include <ctime>
#include <cstdlib>

int main(){
	srand(time(NULL)); 
	while(true){
		const int a = rand() % 20; 
		std::cout << a << std::endl;
		if(a == 10)
			break;
		const int b = rand() % 20;
		std::cout << b << std::endl;
	}
	return 0;
}










Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break




Go: package main

import "fmt"
import "math/rand"
import "time"

func main() {
    rand.Seed(time.Now().UnixNano())
    for {
        a := rand.Intn(20)
        fmt.Println(a)
        if a == 10 {
            break
        }
        b := rand.Intn(20)
        fmt.Println(b)
    }
}








Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break





Java: import java.util.Random;

Random rand = new Random();
while(true){
    int a = rand.nextInt(20);
    System.out.println(a);
    if(a == 10) break;
    int b = rand.nextInt(20);
    System.out.println(b);
}







Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break







Python: from random import randrange

while True:
    a = randrange(20)
    print(a)
    if a == 10:
        break
    b = randrange(20)
    print(b)





Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break








VB: Public Sub LoopsBreak()
    Dim value As Integer
    Randomize
    Do While True
        value = Int(20 * Rnd)
        Debug.Print value
        If value = 10 Then Exit Do
        Debug.Print Int(20 * Rnd)
    Loop
End Sub




Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break

C: int main(){
	time_t t;
	int a, b;
	srand((unsigned)time(&t));
	for(;;){
		a = rand() % 20;
		printf("%d\n", a);
		if(a == 10)
			break;
		b = rand() % 20;
		printf("%d\n", b);
	}
	return 0;
}
Task: Loops_Break



C#: class Program
{
    static void Main(string[] args)
    {
        Random random = new Random();
        while (true)
        {
            int a = random.Next(20);
            Console.WriteLine(a);
            if (a == 10)
                break;
            int b = random.Next(20)
            Console.WriteLine(b);
        }
           
        Console.ReadLine();
    }       
}
Task: Loops_Break


C++: #include <iostream>
#include <ctime>
#include <cstdlib>

int main(){
	srand(time(NULL)); 
	while(true){
		const int a = rand() % 20; 
		std::cout << a << std::endl;
		if(a == 10)
			break;
		const int b = rand() % 20;
		std::cout << b << std::endl;
	}
	return 0;
}
Task: Loops_Break





Java: import java.util.Random;

Random rand = new Random();
while(true){
    int a = rand.nextInt(20);
    System.out.println(a);
    if(a == 10) break;
    int b = rand.nextInt(20);
    System.out.println(b);
}
Task: Loops_Break







Python: from random import randrange

while True:
    a = randrange(20)
    print(a)
    if a == 10:
        break
    b = randrange(20)
    print(b)
Task: Loops_Break








VB: Public Sub LoopsBreak()
    Dim value As Integer
    Randomize
    Do While True
        value = Int(20 * Rnd)
        Debug.Print value
        If value = 10 Then Exit Do
        Debug.Print Int(20 * Rnd)
    Loop
End Sub
Task: Loops_Break




Go: package main

import "fmt"
import "math/rand"
import "time"

func main() {
    rand.Seed(time.Now().UnixNano())
    for {
        a := rand.Intn(20)
        fmt.Println(a)
        if a == 10 {
            break
        }
        b := rand.Intn(20)
        fmt.Println(b)
    }
}
Task: Loops_Break



C#: class Program
{
    static void Main(string[] args)
    {
        Random random = new Random();
        while (true)
        {
            int a = random.Next(20);
            Console.WriteLine(a);
            if (a == 10)
                break;
            int b = random.Next(20)
            Console.WriteLine(b);
        }
           
        Console.ReadLine();
    }       
}








Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break


C++: #include <iostream>
#include <ctime>
#include <cstdlib>

int main(){
	srand(time(NULL)); 
	while(true){
		const int a = rand() % 20; 
		std::cout << a << std::endl;
		if(a == 10)
			break;
		const int b = rand() % 20;
		std::cout << b << std::endl;
	}
	return 0;
}









Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break

C: int main(){
	time_t t;
	int a, b;
	srand((unsigned)time(&t));
	for(;;){
		a = rand() % 20;
		printf("%d\n", a);
		if(a == 10)
			break;
		b = rand() % 20;
		printf("%d\n", b);
	}
	return 0;
}










Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break





Java: import java.util.Random;

Random rand = new Random();
while(true){
    int a = rand.nextInt(20);
    System.out.println(a);
    if(a == 10) break;
    int b = rand.nextInt(20);
    System.out.println(b);
}






Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break







Python: from random import randrange

while True:
    a = randrange(20)
    print(a)
    if a == 10:
        break
    b = randrange(20)
    print(b)




Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break








VB: Public Sub LoopsBreak()
    Dim value As Integer
    Randomize
    Do While True
        value = Int(20 * Rnd)
        Debug.Print value
        If value = 10 Then Exit Do
        Debug.Print Int(20 * Rnd)
    Loop
End Sub



Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break






PHP: while (true) {
    $a = rand(0,19);
    echo "$a\n";
    if ($a == 10)
        break;
    $b = rand(0,19);
    echo "$b\n";
}





Fortran: program Example
  implicit none

  real :: r
  integer :: a, b

  do
     call random_number(r)
     a = int(r * 20)
     write(*,*) a
     if (a == 10) exit
     call random_number(r)
     b = int(r * 20)
     write(*,*) b
  end do

end program Example
Task: Loops_Break

C: int main(){
	time_t t;
	int a, b;
	srand((unsigned)time(&t));
	for(;;){
		a = rand() % 20;
		printf("%d\n", a);
		if(a == 10)
			break;
		b = rand() % 20;
		printf("%d\n", b);
	}
	return 0;
}









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break



C#: class Program
{
    static void Main(string[] args)
    {
        Random random = new Random();
        while (true)
        {
            int a = random.Next(20);
            Console.WriteLine(a);
            if (a == 10)
                break;
            int b = random.Next(20)
            Console.WriteLine(b);
        }
           
        Console.ReadLine();
    }       
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break


C++: #include <iostream>
#include <ctime>
#include <cstdlib>

int main(){
	srand(time(NULL)); 
	while(true){
		const int a = rand() % 20; 
		std::cout << a << std::endl;
		if(a == 10)
			break;
		const int b = rand() % 20;
		std::cout << b << std::endl;
	}
	return 0;
}








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break





Java: import java.util.Random;

Random rand = new Random();
while(true){
    int a = rand.nextInt(20);
    System.out.println(a);
    if(a == 10) break;
    int b = rand.nextInt(20);
    System.out.println(b);
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break







Python: from random import randrange

while True:
    a = randrange(20)
    print(a)
    if a == 10:
        break
    b = randrange(20)
    print(b)



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break








VB: Public Sub LoopsBreak()
    Dim value As Integer
    Randomize
    Do While True
        value = Int(20 * Rnd)
        Debug.Print value
        If value = 10 Then Exit Do
        Debug.Print Int(20 * Rnd)
    Loop
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break




Go: package main

import "fmt"
import "math/rand"
import "time"

func main() {
    rand.Seed(time.Now().UnixNano())
    for {
        a := rand.Intn(20)
        fmt.Println(a)
        if a == 10 {
            break
        }
        b := rand.Intn(20)
        fmt.Println(b)
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Loops_Break






PHP: while (true) {
    $a = rand(0,19);
    echo "$a\n";
    if ($a == 10)
        break;
    $b = rand(0,19);
    echo "$b\n";
}
Task: Loops_Break






PHP: while (true) {
    $a = rand(0,19);
    echo "$a\n";
    if ($a == 10)
        break;
    $b = rand(0,19);
    echo "$b\n";
}






Ada: with Ada.Text_IO;  use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;

procedure Test_Loop_Break is
   type Value_Type is range 0..19;
   package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
   use Random_Values;
   Dice : Generator;
   A, B : Value_Type;
begin
   loop
      A := Random (Dice);
      Put_Line (Value_Type'Image (A));
      exit when A = 10;
      B := Random (Dice);
      Put_Line (Value_Type'Image (B));
   end loop;
end Test_Loop_Break;
Task: Loops_Break






PHP: while (true) {
    $a = rand(0,19);
    echo "$a\n";
    if ($a == 10)
        break;
    $b = rand(0,19);
    echo "$b\n";
}




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. Random-Nums.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  Num  PIC Z9.

       PROCEDURE DIVISION.
       Main.
           PERFORM FOREVER
               PERFORM Generate-And-Display-Num

               IF Num = 10
                   EXIT PERFORM
               ELSE
                   PERFORM Generate-And-Display-Num
               END-IF
           END-PERFORM

           GOBACK
           .

       Generate-And-Display-Num.
           COMPUTE Num =  FUNCTION REM(FUNCTION RANDOM * 100, 20)
           DISPLAY Num
           .
Task: Non-decimal radices_Convert

C: #include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>

char *to_base(int64_t num, int base)
{
  char *tbl = "0123456789abcdefghijklmnopqrstuvwxyz";
  char buf[66] = {'\0'};
  char *out;
  uint64_t n;
  int i, len = 0, neg = 0;
  if (base > 36) {
    fprintf(stderr, "base %d too large\n", base);
    return 0;
  }

   
  n = ((neg = num < 0)) ? (~num) + 1 : num;

  do { buf[len++] = tbl[n % base]; } while(n /= base);

  out = malloc(len + neg + 1);
  for (i = neg; len > 0; i++) out[i] = buf[--len];
  if (neg) out[0] = '-';

  return out;
}

long from_base(const char *num_str, int base)
{
  char *endptr;
  
  
  int result = strtol(num_str, &endptr, base);
  return result;
}

int main()
{
  int64_t x;
  x = ~(1LL << 63) + 1;
  printf("%lld in base 2: %s\n", x, to_base(x, 2));
  x = 383;
  printf("%lld in base 16: %s\n", x, to_base(x, 16));
  return 0;
}











Ada: with Ada.Text_Io; use Ada.Text_Io;
with Ada.Strings.Fixed;
With Ada.Strings.Unbounded;

procedure Number_Base_Conversion is
   Max_Base : constant := 36;
   subtype Base_Type is Integer range 2..Max_Base;
   Num_Digits : constant String := "0123456789abcdefghijklmnopqrstuvwxyz";
   Invalid_Digit : exception;
   
   function To_Decimal(Value : String; Base : Base_Type) return Integer is
      use Ada.Strings.Fixed;
      Result : Integer := 0;
      Decimal_Value : Integer;
      Radix_Offset : Natural := 0;
   begin
      for I in reverse Value'range loop
         Decimal_Value := Index(Num_Digits, Value(I..I)) - 1;
         if Decimal_Value < 0 then
            raise Invalid_Digit;
         end if; 
         Result := Result + (Base**Radix_Offset * Decimal_Value);
         Radix_Offset := Radix_Offset + 1;
      end loop;
      return Result;
   end To_Decimal;
   
   function To_Base(Value : Natural; Base : Base_Type) return String is
      use Ada.Strings.Unbounded;
      Result : Unbounded_String := Null_Unbounded_String;
      Temp : Natural := Value;
      Base_Digit : String(1..1);
   begin
      if Temp = 0 then
         return "0";
      end if;
      while Temp > 0 loop
         Base_Digit(1) := Num_Digits((Temp mod Base) + 1);
         if Result = Null_Unbounded_String then
            Append(Result, Base_Digit);
         else
            Insert(Source => Result,
               Before => 1,
               New_Item => Base_Digit);
         end if;
         Temp := Temp / Base;
      end loop;
      return To_String(Result);
   end To_Base;
   
begin
   Put_Line("26 converted to base 16 is " & To_Base(26, 16));
   Put_line("1a (base 16) is decimal" & Integer'image(To_Decimal("1a", 16)));
end Number_Base_Conversion;
Task: Non-decimal radices_Convert


C++: #include <string>
#include <cstdlib>
#include <algorithm>
#include <cassert>

std::string const digits = "0123456789abcdefghijklmnopqrstuvwxyz";

std::string to_base(unsigned long num, int base)
{
  if (num == 0)
    return "0";
  
  std::string result;
  while (num > 0) {
    std::ldiv_t temp = std::div(num, (long)base);
    result += digits[temp.rem];
    num = temp.quot;
  }
  std::reverse(result.begin(), result.end());
  return result;
}

unsigned long from_base(std::string const& num_str, int base)
{
  unsigned long result = 0;
  for (std::string::size_type pos = 0; pos < num_str.length(); ++pos)
    result = result * base + digits.find(num_str[pos]);
  return result;
}










Ada: with Ada.Text_Io; use Ada.Text_Io;
with Ada.Strings.Fixed;
With Ada.Strings.Unbounded;

procedure Number_Base_Conversion is
   Max_Base : constant := 36;
   subtype Base_Type is Integer range 2..Max_Base;
   Num_Digits : constant String := "0123456789abcdefghijklmnopqrstuvwxyz";
   Invalid_Digit : exception;
   
   function To_Decimal(Value : String; Base : Base_Type) return Integer is
      use Ada.Strings.Fixed;
      Result : Integer := 0;
      Decimal_Value : Integer;
      Radix_Offset : Natural := 0;
   begin
      for I in reverse Value'range loop
         Decimal_Value := Index(Num_Digits, Value(I..I)) - 1;
         if Decimal_Value < 0 then
            raise Invalid_Digit;
         end if; 
         Result := Result + (Base**Radix_Offset * Decimal_Value);
         Radix_Offset := Radix_Offset + 1;
      end loop;
      return Result;
   end To_Decimal;
   
   function To_Base(Value : Natural; Base : Base_Type) return String is
      use Ada.Strings.Unbounded;
      Result : Unbounded_String := Null_Unbounded_String;
      Temp : Natural := Value;
      Base_Digit : String(1..1);
   begin
      if Temp = 0 then
         return "0";
      end if;
      while Temp > 0 loop
         Base_Digit(1) := Num_Digits((Temp mod Base) + 1);
         if Result = Null_Unbounded_String then
            Append(Result, Base_Digit);
         else
            Insert(Source => Result,
               Before => 1,
               New_Item => Base_Digit);
         end if;
         Temp := Temp / Base;
      end loop;
      return To_String(Result);
   end To_Base;
   
begin
   Put_Line("26 converted to base 16 is " & To_Base(26, 16));
   Put_line("1a (base 16) is decimal" & Integer'image(To_Decimal("1a", 16)));
end Number_Base_Conversion;
Task: Non-decimal radices_Convert




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
)

func main () {
    s := strconv.FormatInt(26, 16) 
    fmt.Println(s)

    i, err := strconv.ParseInt("1a", 16, 64) 
    if err == nil {
        fmt.Println(i)
    }
    b, ok := new(big.Int).SetString("1a", 16) 
    if ok {
        fmt.Println(b)
    }
}








Ada: with Ada.Text_Io; use Ada.Text_Io;
with Ada.Strings.Fixed;
With Ada.Strings.Unbounded;

procedure Number_Base_Conversion is
   Max_Base : constant := 36;
   subtype Base_Type is Integer range 2..Max_Base;
   Num_Digits : constant String := "0123456789abcdefghijklmnopqrstuvwxyz";
   Invalid_Digit : exception;
   
   function To_Decimal(Value : String; Base : Base_Type) return Integer is
      use Ada.Strings.Fixed;
      Result : Integer := 0;
      Decimal_Value : Integer;
      Radix_Offset : Natural := 0;
   begin
      for I in reverse Value'range loop
         Decimal_Value := Index(Num_Digits, Value(I..I)) - 1;
         if Decimal_Value < 0 then
            raise Invalid_Digit;
         end if; 
         Result := Result + (Base**Radix_Offset * Decimal_Value);
         Radix_Offset := Radix_Offset + 1;
      end loop;
      return Result;
   end To_Decimal;
   
   function To_Base(Value : Natural; Base : Base_Type) return String is
      use Ada.Strings.Unbounded;
      Result : Unbounded_String := Null_Unbounded_String;
      Temp : Natural := Value;
      Base_Digit : String(1..1);
   begin
      if Temp = 0 then
         return "0";
      end if;
      while Temp > 0 loop
         Base_Digit(1) := Num_Digits((Temp mod Base) + 1);
         if Result = Null_Unbounded_String then
            Append(Result, Base_Digit);
         else
            Insert(Source => Result,
               Before => 1,
               New_Item => Base_Digit);
         end if;
         Temp := Temp / Base;
      end loop;
      return To_String(Result);
   end To_Base;
   
begin
   Put_Line("26 converted to base 16 is " & To_Base(26, 16));
   Put_line("1a (base 16) is decimal" & Integer'image(To_Decimal("1a", 16)));
end Number_Base_Conversion;