WeixiangYan/CodeTransOcean huggingface dataset:
Task: Concurrent computing



C#: static Random tRand = new Random();

static void Main(string[] args)
{
	Thread t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Enjoy");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Rosetta");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Code");

	Console.ReadLine();
}

private static void WriteText(object p)
{
	Thread.Sleep(tRand.Next(1000, 4000));
	Console.WriteLine(p);
}









Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing

C: #include <stdio.h>
#include <unistd.h>
#include <pthread.h>

pthread_mutex_t condm = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
int bang = 0;

#define WAITBANG() do { \
   pthread_mutex_lock(&condm); \
   while( bang == 0 ) \
   { \
      pthread_cond_wait(&cond, &condm); \
   } \
   pthread_mutex_unlock(&condm); } while(0);\

void *t_enjoy(void *p)
{
  WAITBANG();
  printf("Enjoy\n");
  pthread_exit(0);
}

void *t_rosetta(void *p)
{
  WAITBANG();
  printf("Rosetta\n");
  pthread_exit(0);
}

void *t_code(void *p)
{
  WAITBANG();
  printf("Code\n");
  pthread_exit(0);
}

typedef void *(*threadfunc)(void *);
int main()
{
   int i;
   pthread_t a[3];
   threadfunc p[3] = {t_enjoy, t_rosetta, t_code};
   
   for(i=0;i<3;i++)
   {
     pthread_create(&a[i], NULL, p[i], NULL);
   }
   sleep(1);
   bang = 1;
   pthread_cond_broadcast(&cond);
   for(i=0;i<3;i++)
   {
     pthread_join(a[i], NULL);
   }
}











Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing


C++: #include <thread>
#include <iostream>
#include <vector>
#include <random>
#include <chrono> 

int main()
{
  std::random_device rd;
  std::mt19937 eng(rd()); 
  std::uniform_int_distribution<> dist(1,1000);
  std::vector<std::thread> threads;

  for(const auto& str: {"Enjoy\n", "Rosetta\n", "Code\n"}) {
    
    std::chrono::milliseconds duration(dist(eng)); 

    threads.emplace_back([str, duration](){                                                                    
      std::this_thread::sleep_for(duration);
      std::cout << str;
    });
  }

  for(auto& t: threads) t.join(); 

  return 0;
}










Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing




Go: package main
  
import (
    "fmt"
    "golang.org/x/exp/rand"
    "time"
)

func main() {
    words := []string{"Enjoy", "Rosetta", "Code"}
    seed := uint64(time.Now().UnixNano())
    q := make(chan string)
    for i, w := range words {
        go func(w string, seed uint64) {
            r := rand.New(rand.NewSource(seed))
            time.Sleep(time.Duration(r.Int63n(1e9)))
            q <- w
        }(w, seed+uint64(i))
    }
    for i := 0; i < len(words); i++ {
        fmt.Println(<-q)
    }
}








Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing





Java: import java.util.concurrent.CyclicBarrier;

public class Threads
{
  public static class DelayedMessagePrinter implements Runnable
  {
    private CyclicBarrier barrier;
    private String msg;
    
    public DelayedMessagePrinter(CyclicBarrier barrier, String msg)
    {
      this.barrier = barrier;
      this.msg = msg;
    }
    
    public void run()
    {
      try
      {  barrier.await();  }
      catch (Exception e)
      {  }
      System.out.println(msg);
    }
  }
  
  public static void main(String[] args)
  {
    CyclicBarrier barrier = new CyclicBarrier(3);
    new Thread(new DelayedMessagePrinter(barrier, "Enjoy")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Rosetta")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Code")).start();
  }
}







Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing







Python: let words = ["Enjoy", "Rosetta", "Code"]

for word in words:
    (word) |> async (w) =>
        sleep(random())
        print(w)





Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing








VB: Private Sub Enjoy()
    Debug.Print "Enjoy"
End Sub
Private Sub Rosetta()
    Debug.Print "Rosetta"
End Sub
Private Sub Code()
    Debug.Print "Code"
End Sub
Public Sub concurrent()
    when = Now + TimeValue("00:00:01")
    Application.OnTime when, "Enjoy"
    Application.OnTime when, "Rosetta"
    Application.OnTime when, "Code"
End Sub




Ada: with Ada.Text_IO, Ada.Numerics.Float_Random;

procedure Concurrent_Hello is
   type Messages is (Enjoy, Rosetta, Code);
   task type Writer (Message : Messages);
   task body Writer is
      Seed : Ada.Numerics.Float_Random.Generator;
   begin
      Ada.Numerics.Float_Random.Reset (Seed); 
      delay Duration (Ada.Numerics.Float_Random.Random (Seed));
      Ada.Text_IO.Put_Line (Messages'Image(Message));
   end Writer;
   Taks: array(Messages) of access Writer 
     := (new Writer(Enjoy), new Writer(Rosetta), new Writer(Code));
begin
   null; 
end Concurrent_Hello;
Task: Concurrent computing

C: #include <stdio.h>
#include <unistd.h>
#include <pthread.h>

pthread_mutex_t condm = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
int bang = 0;

#define WAITBANG() do { \
   pthread_mutex_lock(&condm); \
   while( bang == 0 ) \
   { \
      pthread_cond_wait(&cond, &condm); \
   } \
   pthread_mutex_unlock(&condm); } while(0);\

void *t_enjoy(void *p)
{
  WAITBANG();
  printf("Enjoy\n");
  pthread_exit(0);
}

void *t_rosetta(void *p)
{
  WAITBANG();
  printf("Rosetta\n");
  pthread_exit(0);
}

void *t_code(void *p)
{
  WAITBANG();
  printf("Code\n");
  pthread_exit(0);
}

typedef void *(*threadfunc)(void *);
int main()
{
   int i;
   pthread_t a[3];
   threadfunc p[3] = {t_enjoy, t_rosetta, t_code};
   
   for(i=0;i<3;i++)
   {
     pthread_create(&a[i], NULL, p[i], NULL);
   }
   sleep(1);
   bang = 1;
   pthread_cond_broadcast(&cond);
   for(i=0;i<3;i++)
   {
     pthread_join(a[i], NULL);
   }
}
Task: Concurrent computing



C#: static Random tRand = new Random();

static void Main(string[] args)
{
	Thread t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Enjoy");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Rosetta");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Code");

	Console.ReadLine();
}

private static void WriteText(object p)
{
	Thread.Sleep(tRand.Next(1000, 4000));
	Console.WriteLine(p);
}
Task: Concurrent computing


C++: #include <thread>
#include <iostream>
#include <vector>
#include <random>
#include <chrono> 

int main()
{
  std::random_device rd;
  std::mt19937 eng(rd()); 
  std::uniform_int_distribution<> dist(1,1000);
  std::vector<std::thread> threads;

  for(const auto& str: {"Enjoy\n", "Rosetta\n", "Code\n"}) {
    
    std::chrono::milliseconds duration(dist(eng)); 

    threads.emplace_back([str, duration](){                                                                    
      std::this_thread::sleep_for(duration);
      std::cout << str;
    });
  }

  for(auto& t: threads) t.join(); 

  return 0;
}
Task: Concurrent computing





Java: import java.util.concurrent.CyclicBarrier;

public class Threads
{
  public static class DelayedMessagePrinter implements Runnable
  {
    private CyclicBarrier barrier;
    private String msg;
    
    public DelayedMessagePrinter(CyclicBarrier barrier, String msg)
    {
      this.barrier = barrier;
      this.msg = msg;
    }
    
    public void run()
    {
      try
      {  barrier.await();  }
      catch (Exception e)
      {  }
      System.out.println(msg);
    }
  }
  
  public static void main(String[] args)
  {
    CyclicBarrier barrier = new CyclicBarrier(3);
    new Thread(new DelayedMessagePrinter(barrier, "Enjoy")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Rosetta")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Code")).start();
  }
}
Task: Concurrent computing







Python: let words = ["Enjoy", "Rosetta", "Code"]

for word in words:
    (word) |> async (w) =>
        sleep(random())
        print(w)
Task: Concurrent computing








VB: Private Sub Enjoy()
    Debug.Print "Enjoy"
End Sub
Private Sub Rosetta()
    Debug.Print "Rosetta"
End Sub
Private Sub Code()
    Debug.Print "Code"
End Sub
Public Sub concurrent()
    when = Now + TimeValue("00:00:01")
    Application.OnTime when, "Enjoy"
    Application.OnTime when, "Rosetta"
    Application.OnTime when, "Code"
End Sub
Task: Concurrent computing




Go: package main
  
import (
    "fmt"
    "golang.org/x/exp/rand"
    "time"
)

func main() {
    words := []string{"Enjoy", "Rosetta", "Code"}
    seed := uint64(time.Now().UnixNano())
    q := make(chan string)
    for i, w := range words {
        go func(w string, seed uint64) {
            r := rand.New(rand.NewSource(seed))
            time.Sleep(time.Duration(r.Int63n(1e9)))
            q <- w
        }(w, seed+uint64(i))
    }
    for i := 0; i < len(words); i++ {
        fmt.Println(<-q)
    }
}
Task: Concurrent computing



C#: static Random tRand = new Random();

static void Main(string[] args)
{
	Thread t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Enjoy");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Rosetta");

	t = new Thread(new ParameterizedThreadStart(WriteText));
	t.Start("Code");

	Console.ReadLine();
}

private static void WriteText(object p)
{
	Thread.Sleep(tRand.Next(1000, 4000));
	Console.WriteLine(p);
}








Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Concurrent computing


C++: #include <thread>
#include <iostream>
#include <vector>
#include <random>
#include <chrono> 

int main()
{
  std::random_device rd;
  std::mt19937 eng(rd()); 
  std::uniform_int_distribution<> dist(1,1000);
  std::vector<std::thread> threads;

  for(const auto& str: {"Enjoy\n", "Rosetta\n", "Code\n"}) {
    
    std::chrono::milliseconds duration(dist(eng)); 

    threads.emplace_back([str, duration](){                                                                    
      std::this_thread::sleep_for(duration);
      std::cout << str;
    });
  }

  for(auto& t: threads) t.join(); 

  return 0;
}









Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Concurrent computing

C: #include <stdio.h>
#include <unistd.h>
#include <pthread.h>

pthread_mutex_t condm = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
int bang = 0;

#define WAITBANG() do { \
   pthread_mutex_lock(&condm); \
   while( bang == 0 ) \
   { \
      pthread_cond_wait(&cond, &condm); \
   } \
   pthread_mutex_unlock(&condm); } while(0);\

void *t_enjoy(void *p)
{
  WAITBANG();
  printf("Enjoy\n");
  pthread_exit(0);
}

void *t_rosetta(void *p)
{
  WAITBANG();
  printf("Rosetta\n");
  pthread_exit(0);
}

void *t_code(void *p)
{
  WAITBANG();
  printf("Code\n");
  pthread_exit(0);
}

typedef void *(*threadfunc)(void *);
int main()
{
   int i;
   pthread_t a[3];
   threadfunc p[3] = {t_enjoy, t_rosetta, t_code};
   
   for(i=0;i<3;i++)
   {
     pthread_create(&a[i], NULL, p[i], NULL);
   }
   sleep(1);
   bang = 1;
   pthread_cond_broadcast(&cond);
   for(i=0;i<3;i++)
   {
     pthread_join(a[i], NULL);
   }
}










Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Concurrent computing





Java: import java.util.concurrent.CyclicBarrier;

public class Threads
{
  public static class DelayedMessagePrinter implements Runnable
  {
    private CyclicBarrier barrier;
    private String msg;
    
    public DelayedMessagePrinter(CyclicBarrier barrier, String msg)
    {
      this.barrier = barrier;
      this.msg = msg;
    }
    
    public void run()
    {
      try
      {  barrier.await();  }
      catch (Exception e)
      {  }
      System.out.println(msg);
    }
  }
  
  public static void main(String[] args)
  {
    CyclicBarrier barrier = new CyclicBarrier(3);
    new Thread(new DelayedMessagePrinter(barrier, "Enjoy")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Rosetta")).start();
    new Thread(new DelayedMessagePrinter(barrier, "Code")).start();
  }
}






Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Concurrent computing







Python: let words = ["Enjoy", "Rosetta", "Code"]

for word in words:
    (word) |> async (w) =>
        sleep(random())
        print(w)




Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Concurrent computing








VB: Private Sub Enjoy()
    Debug.Print "Enjoy"
End Sub
Private Sub Rosetta()
    Debug.Print "Rosetta"
End Sub
Private Sub Code()
    Debug.Print "Code"
End Sub
Public Sub concurrent()
    when = Now + TimeValue("00:00:01")
    Application.OnTime when, "Enjoy"
    Application.OnTime when, "Rosetta"
    Application.OnTime when, "Code"
End Sub



Fortran: program concurrency
  implicit none
  character(len=*), parameter :: str1 = 'Enjoy'
  character(len=*), parameter :: str2 = 'Rosetta'
  character(len=*), parameter :: str3 = 'Code'
  integer                     :: i
  real                        :: h
  real, parameter             :: one_third = 1.0e0/3
  real, parameter             :: two_thirds = 2.0e0/3

  interface
     integer function omp_get_thread_num
     end function omp_get_thread_num
  end interface
  interface
     integer function omp_get_num_threads
     end function omp_get_num_threads
  end interface

  
  
  do i=1,20
     
     
     if (omp_get_thread_num() == 0 .and. i == 1) then
        write(*,'(a,i0,a)') 'Using ',omp_get_num_threads(),' threads'
     end if

     
     call random_number(h)

     
     if (h < one_third) then
        write(*,'(a)') str1
     else if (h < two_thirds) then
        write(*,'(a)') str2
     else
        write(*,'(a)') str3
     end if
     
  end do
  

end program concurrency
Task: Strip a set of characters from a string



C#: using System;

public static string RemoveCharactersFromString(string testString, string removeChars)
{
    char[] charAry = removeChars.ToCharArray();
    string returnString = testString;
    foreach (char c in charAry)
    {
        while (returnString.IndexOf(c) > -1)
        {
            returnString = returnString.Remove(returnString.IndexOf(c), 1);
        }
    }
    return returnString;
}









Ada: with Ada.Text_IO;

procedure Strip_Characters_From_String is

   function Strip(The_String: String; The_Characters: String)
                  return String is
      Keep:   array (Character) of Boolean := (others => True);
      Result: String(The_String'Range);
      Last:   Natural := Result'First-1;
   begin
      for I in The_Characters'Range loop
         Keep(The_Characters(I)) := False;
      end loop;
      for J in The_String'Range loop
         if Keep(The_String(J)) then
            Last := Last+1;
            Result(Last) := The_String(J);
         end if;
      end loop;
      return Result(Result'First .. Last);
   end Strip;

   S: String := "She was a soul stripper. She took my heart!";

begin 
   Ada.Text_IO.Put_Line(Strip(S, "aei"));
end Strip_Characters_From_String;
Task: Strip a set of characters from a string

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

  
char *strip_chars(const char *string, const char *chars)
{
  char * newstr = malloc(strlen(string) + 1);
  int counter = 0;

  for ( ; *string; string++) {
    if (!strchr(chars, *string)) {
      newstr[ counter ] = *string;
      ++ counter;
    }
  }

  newstr[counter] = 0;
  return newstr;
}

int main(void)
{
  char *new = strip_chars("She was a soul stripper. She took my heart!", "aei");
  printf("%s\n", new);

  free(new);
  return 0;
}











Ada: with Ada.Text_IO;

procedure Strip_Characters_From_String is

   function Strip(The_String: String; The_Characters: String)
                  return String is
      Keep:   array (Character) of Boolean := (others => True);
      Result: String(The_String'Range);
      Last:   Natural := Result'First-1;
   begin
      for I in The_Characters'Range loop
         Keep(The_Characters(I)) := False;
      end loop;
      for J in The_String'Range loop
         if Keep(The_String(J)) then
            Last := Last+1;
            Result(Last) := The_String(J);
         end if;
      end loop;
      return Result(Result'First .. Last);
   end Strip;

   S: String := "She was a soul stripper. She took my heart!";

begin 
   Ada.Text_IO.Put_Line(Strip(S, "aei"));
end Strip_Characters_From_String;