WeixiangYan/CodeTransOcean huggingface dataset:
Task: Polymorphism




Go: package main

import "fmt"

type point struct {
    x, y float64
}

type circle struct {
    x, y, r float64
}

type printer interface {
    print()
}

func (p *point) print() {
    fmt.Println(p.x, p.y)
}

func (c *circle) print() {
    fmt.Println(c.x, c.y, c.r)
}

func main() {
    var i printer            
    i = newPoint(3, 4)       
    i.print()                
    i = newCircle(5, 12, 13) 
    i.print()                
}












func (p *point) getX() float64  { return p.x }
func (p *point) getY() float64  { return p.y }
func (p *point) setX(v float64) { p.x = v }
func (p *point) setY(v float64) { p.y = v }

func (c *circle) getX() float64  { return c.x }
func (c *circle) getY() float64  { return c.y }
func (c *circle) getR() float64  { return c.r }
func (c *circle) setX(v float64) { c.x = v }
func (c *circle) setY(v float64) { c.y = v }
func (c *circle) setR(v float64) { c.r = v }



func (p *point) clone() *point   { r := *p; return &r }
func (c *circle) clone() *circle { r := *c; return &r }


func (p *point) set(q *point)   { *p = *q }
func (c *circle) set(d *circle) { *c = *d }










func newPoint(x, y float64) *point {
    return &point{x, y}
}
func newCircle(x, y, r float64) *circle {
    return &circle{x, y, r}
}
Task: Polymorphism






PHP: class Point
{
  protected $_x;

  protected $_y;
  
  public function __construct()
  {
    switch( func_num_args() )
    {
      case 1:
        $point = func_get_arg( 0 );
        $this->setFromPoint( $point );
        break;
      case 2:
        $x = func_get_arg( 0 );
        $y = func_get_arg( 1 );
        $this->setX( $x );
        $this->setY( $y );
        break;
      default:
        throw new InvalidArgumentException( 'expecting one (Point) argument or two (numeric x and y) arguments' );
    }
  }
  
  public function setFromPoint( Point $point )
  {
    $this->setX( $point->getX() );
    $this->setY( $point->getY() );
  }
  
  public function getX()
  {
    return $this->_x;
  }
  
  public function setX( $x )
  {
    if( !is_numeric( $x ) )
    {
      throw new InvalidArgumentException( 'expecting numeric value' );
    }
    
    $this->_x = (float) $x;
  }
  
  public function getY()
  {
    return $this->_y;
  }
  
  public function setY( $y )
  {
    if( !is_numeric( $y ) )
    {
      throw new InvalidArgumentException( 'expecting numeric value' );
    }
    
    $this->_y = (float) $y;
  }
  
  public function output()
  {
    echo $this->__toString();
  }
  
  public function __toString()
  {
    return 'Point [x:' . $this->_x . ',y:' . $this->_y . ']';
  }
}






Ada: package Shapes is
   type Point is tagged private;
   procedure Print(Item : in Point);
   function Setx(Item : in Point; Val : Integer) return Point;
   function Sety(Item : in Point; Val : Integer) return Point;
   function Getx(Item : in Point) return Integer;
   function Gety(Item : in Point) return Integer;
   function Create return Point;
   function Create(X : Integer) return Point;
   function Create(X, Y : Integer) return Point;
  
private
   type Point is tagged record
      X : Integer := 0;
      Y : Integer := 0;
   end record;
end Shapes;
Task: Polymorphism






PHP: class Point
{
  protected $_x;

  protected $_y;
  
  public function __construct()
  {
    switch( func_num_args() )
    {
      case 1:
        $point = func_get_arg( 0 );
        $this->setFromPoint( $point );
        break;
      case 2:
        $x = func_get_arg( 0 );
        $y = func_get_arg( 1 );
        $this->setX( $x );
        $this->setY( $y );
        break;
      default:
        throw new InvalidArgumentException( 'expecting one (Point) argument or two (numeric x and y) arguments' );
    }
  }
  
  public function setFromPoint( Point $point )
  {
    $this->setX( $point->getX() );
    $this->setY( $point->getY() );
  }
  
  public function getX()
  {
    return $this->_x;
  }
  
  public function setX( $x )
  {
    if( !is_numeric( $x ) )
    {
      throw new InvalidArgumentException( 'expecting numeric value' );
    }
    
    $this->_x = (float) $x;
  }
  
  public function getY()
  {
    return $this->_y;
  }
  
  public function setY( $y )
  {
    if( !is_numeric( $y ) )
    {
      throw new InvalidArgumentException( 'expecting numeric value' );
    }
    
    $this->_y = (float) $y;
  }
  
  public function output()
  {
    echo $this->__toString();
  }
  
  public function __toString()
  {
    return 'Point [x:' . $this->_x . ',y:' . $this->_y . ']';
  }
}
Task: Semiprime



C#: static void Main(string[] args)
{
    
    for (int i = 0; i < 50; i++)
    {
        Console.WriteLine("{0}\t{1} ", i,isSemiPrime(i));
    }
    Console.ReadLine();
}


private static bool isSemiPrime(int c)
{
    int a = 2, b = 0;
    while (b < 3 && c != 1)
    {
        if ((c % a) == 0)
        {
            c /= a;
            b++;
        }
        else
        {
            a++;
        };
    }
    return b == 2;
}









Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime

C: #include <stdio.h>

int semiprime(int n)
{
	int p, f = 0;
	for (p = 2; f < 2 && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == 2;
}

int main(void)
{
	int i;
	for (i = 2; i < 100; i++)
		if (semiprime(i)) printf(" %d", i);
	putchar('\n');

	return 0;
}











Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime


C++: #include <iostream>

bool isSemiPrime( int c )
{
    int a = 2, b = 0;
    while( b < 3 && c != 1 )
    {
	if( !( c % a ) ) 
	{ c /= a; b++; }
	else a++;
    }
    return b == 2;
}
int main( int argc, char* argv[] )
{
    for( int x = 2; x < 100; x++ )
	if( isSemiPrime( x ) )
	    std::cout << x << " ";

    return 0;
}










Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime




Go: package main

import "fmt"

func semiprime(n int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == 2 {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == 2
}

func main() {
    for v := 1675; v <= 1680; v++ {
        fmt.Println(v, "->", semiprime(v))
    }
}








Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime





Java: import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class SemiPrime{
	private static final BigInteger TWO = BigInteger.valueOf(2);
	 
	public static List<BigInteger> primeDecomp(BigInteger a){
	    
	    if(a.compareTo(TWO) < 0){
	        return null; 
	    }
	 
	    
	    List<BigInteger> result = new ArrayList<BigInteger>();
	    while(a.and(BigInteger.ONE).equals(BigInteger.ZERO)){
	        a = a.shiftRight(1);
	        result.add(TWO);
	    }
	 
	    
	    if(!a.equals(BigInteger.ONE)){
	        BigInteger b = BigInteger.valueOf(3);
	        while(b.compareTo(a) < 0){
	            if(b.isProbablePrime(10)){
	                BigInteger[] dr = a.divideAndRemainder(b);
	                if(dr[1].equals(BigInteger.ZERO)){
	                    result.add(b);
	                    a = dr[0];
	                }
	            }
	            b = b.add(TWO);
	        }
	        result.add(b); 
	    }
	    return result;
	}
	
	public static boolean isSemi(BigInteger x){
		List<BigInteger> decomp = primeDecomp(x);
		return decomp != null && decomp.size() == 2;
	}
	
	public static void main(String[] args){
		for(int i = 2; i <= 100; i++){
			if(isSemi(BigInteger.valueOf(i))){
				System.out.print(i + " ");
			}
		}
		System.out.println();
		for(int i = 1675; i <= 1680; i++){
			if(isSemi(BigInteger.valueOf(i))){
				System.out.print(i + " ");
			}
		}
	}
}







Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime







Python: from prime_decomposition import decompose

def semiprime(n):
    d = decompose(n)
    try:
        return next(d) * next(d) == n
    except StopIteration:
        return False





Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime








VB: function semiprime$(n)
    a = 2
    c = 0
    while c < 3 and n > 1
        if n mod a = 0 then
            n = n / a
            c = c + 1
        else
            a = a + 1
        end if
    wend
    if c = 2 then semiprime$ = "True" else semiprime$ = "False"
end function

for i = 0 to 64
    print i; chr$(9); semiprime$(i)
next i




Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Semiprime

C: #include <stdio.h>

int semiprime(int n)
{
	int p, f = 0;
	for (p = 2; f < 2 && p*p <= n; p++)
		while (0 == n % p)
			n /= p, f++;

	return f + (n > 1) == 2;
}

int main(void)
{
	int i;
	for (i = 2; i < 100; i++)
		if (semiprime(i)) printf(" %d", i);
	putchar('\n');

	return 0;
}
Task: Semiprime



C#: static void Main(string[] args)
{
    
    for (int i = 0; i < 50; i++)
    {
        Console.WriteLine("{0}\t{1} ", i,isSemiPrime(i));
    }
    Console.ReadLine();
}


private static bool isSemiPrime(int c)
{
    int a = 2, b = 0;
    while (b < 3 && c != 1)
    {
        if ((c % a) == 0)
        {
            c /= a;
            b++;
        }
        else
        {
            a++;
        };
    }
    return b == 2;
}
Task: Semiprime


C++: #include <iostream>

bool isSemiPrime( int c )
{
    int a = 2, b = 0;
    while( b < 3 && c != 1 )
    {
	if( !( c % a ) ) 
	{ c /= a; b++; }
	else a++;
    }
    return b == 2;
}
int main( int argc, char* argv[] )
{
    for( int x = 2; x < 100; x++ )
	if( isSemiPrime( x ) )
	    std::cout << x << " ";

    return 0;
}
Task: Semiprime





Java: import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

public class SemiPrime{
	private static final BigInteger TWO = BigInteger.valueOf(2);
	 
	public static List<BigInteger> primeDecomp(BigInteger a){
	    
	    if(a.compareTo(TWO) < 0){
	        return null; 
	    }
	 
	    
	    List<BigInteger> result = new ArrayList<BigInteger>();
	    while(a.and(BigInteger.ONE).equals(BigInteger.ZERO)){
	        a = a.shiftRight(1);
	        result.add(TWO);
	    }
	 
	    
	    if(!a.equals(BigInteger.ONE)){
	        BigInteger b = BigInteger.valueOf(3);
	        while(b.compareTo(a) < 0){
	            if(b.isProbablePrime(10)){
	                BigInteger[] dr = a.divideAndRemainder(b);
	                if(dr[1].equals(BigInteger.ZERO)){
	                    result.add(b);
	                    a = dr[0];
	                }
	            }
	            b = b.add(TWO);
	        }
	        result.add(b); 
	    }
	    return result;
	}
	
	public static boolean isSemi(BigInteger x){
		List<BigInteger> decomp = primeDecomp(x);
		return decomp != null && decomp.size() == 2;
	}
	
	public static void main(String[] args){
		for(int i = 2; i <= 100; i++){
			if(isSemi(BigInteger.valueOf(i))){
				System.out.print(i + " ");
			}
		}
		System.out.println();
		for(int i = 1675; i <= 1680; i++){
			if(isSemi(BigInteger.valueOf(i))){
				System.out.print(i + " ");
			}
		}
	}
}
Task: Semiprime







Python: from prime_decomposition import decompose

def semiprime(n):
    d = decompose(n)
    try:
        return next(d) * next(d) == n
    except StopIteration:
        return False
Task: Semiprime








VB: function semiprime$(n)
    a = 2
    c = 0
    while c < 3 and n > 1
        if n mod a = 0 then
            n = n / a
            c = c + 1
        else
            a = a + 1
        end if
    wend
    if c = 2 then semiprime$ = "True" else semiprime$ = "False"
end function

for i = 0 to 64
    print i; chr$(9); semiprime$(i)
next i
Task: Semiprime




Go: package main

import "fmt"

func semiprime(n int) bool {
    nf := 0
    for i := 2; i <= n; i++ {
        for n%i == 0 {
            if nf == 2 {
                return false
            }
            nf++
            n /= i
        }
    }
    return nf == 2
}

func main() {
    for v := 1675; v <= 1680; v++ {
        fmt.Println(v, "->", semiprime(v))
    }
}
Task: Semiprime






PHP: <?php


function primeFactorsCount($n)
{
    $n = abs($n);
    $count = 0; // Result
    if ($n >= 2)
        for ($factor = 2; $factor <= $n; $factor++)
            while ($n % $factor == 0) {
                $count++;
                $n /= $factor;
            }
    return $count;
}

echo "Enter an integer: ", 
$n = (int)fgets(STDIN);
echo (primeFactorsCount($n) == 2 ? 
      "It is a semiprime.\n" : "It is not a semiprime.\n"); 
?>
Task: Semiprime






PHP: <?php


function primeFactorsCount($n)
{
    $n = abs($n);
    $count = 0; // Result
    if ($n >= 2)
        for ($factor = 2; $factor <= $n; $factor++)
            while ($n % $factor == 0) {
                $count++;
                $n /= $factor;
            }
    return $count;
}

echo "Enter an integer: ", 
$n = (int)fgets(STDIN);
echo (primeFactorsCount($n) == 2 ? 
      "It is a semiprime.\n" : "It is not a semiprime.\n"); 
?>






Ada: with Prime_Numbers, Ada.Text_IO; 
 
procedure Test_Semiprime is
   
   package Integer_Numbers is new 
     Prime_Numbers (Natural, 0, 1, 2); 
   use Integer_Numbers;
   
begin
   for N in 1 .. 100 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop;
   Ada.Text_IO.New_Line;
   for N in 1675 .. 1680 loop
      if Decompose(N)'Length = 2 then 
	 Ada.Text_IO.Put(Integer'Image(Integer(N)));
      end if;
   end loop; 
end Test_Semiprime;
Task: Generate lower case ASCII alphabet



C#: using System;
using System.Linq;

internal class Program
{
    private static void Main()
    {
        Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c)));
    }
}









Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}











Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet


C++: #include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}










Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}








Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet





Java: public class LowerAscii {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(26);
        for (char ch = 'a'; ch <= 'z'; ch++)
            sb.append(ch);
        System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
    }
}







Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet







Python: 
from string import ascii_lowercase


lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]





Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet








VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function




Ada:    type Lower_Case is new Character range 'a' .. 'z';
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}
Task: Generate lower case ASCII alphabet



C#: using System;
using System.Linq;

internal class Program
{
    private static void Main()
    {
        Console.WriteLine(String.Concat(Enumerable.Range('a', 26).Select(c => (char)c)));
    }
}
Task: Generate lower case ASCII alphabet


C++: #include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}
Task: Generate lower case ASCII alphabet





Java: public class LowerAscii {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(26);
        for (char ch = 'a'; ch <= 'z'; ch++)
            sb.append(ch);
        System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
    }
}
Task: Generate lower case ASCII alphabet







Python: 
from string import ascii_lowercase


lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]
Task: Generate lower case ASCII alphabet








VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function
Task: Generate lower case ASCII alphabet




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}
Task: Generate lower case ASCII alphabet


C++: #include <string>
#include <numeric>

int main() {
    std::string lower(26,' ');

    std::iota(lower.begin(), lower.end(), 'a');
}









Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}










Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet




Go: func loweralpha() string {
	p := make([]byte, 26)
	for i := range p {
		p[i] = 'a' + byte(i)
	}
	return string(p)
}







Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet





Java: public class LowerAscii {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder(26);
        for (char ch = 'a'; ch <= 'z'; ch++)
            sb.append(ch);
        System.out.printf("lower ascii: %s, length: %s", sb, sb.length());
    }
}






Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet







Python: 
from string import ascii_lowercase


lower = [chr(i) for i in range(ord('a'), ord('z') + 1)]




Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet








VB: Option Explicit

Sub Main_Lower_Case_Ascii_Alphabet()
Dim Alpha() As String

    Alpha = Alphabet(97, 122)
    Debug.Print Join(Alpha, ", ")
End Sub

Function Alphabet(FirstAscii As Byte, LastAscii As Byte) As String()
Dim strarrTemp() As String, i&

    ReDim strarrTemp(0 To LastAscii - FirstAscii)
    For i = FirstAscii To LastAscii
        strarrTemp(i - FirstAscii) = Chr(i)
    Next
    Alphabet = strarrTemp
    Erase strarrTemp
End Function



Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet






PHP: <?php
$lower = range('a', 'z');
var_dump($lower);
?>





Fortran:   character(26) :: alpha
  integer :: i

  do i = 1, 26
    alpha(i:i) = achar(iachar('a') + i - 1)
  end do
Task: Generate lower case ASCII alphabet

C: #include <stdlib.h>

#define N 26

int main() {
    unsigned char lower[N];

    for (size_t i = 0; i < N; i++) {
        lower[i] = i + 'a';
    }

    return EXIT_SUCCESS;
}









COBOL: identification division.
program-id. lower-case-alphabet-program.
data division.
working-storage section.
01  ascii-lower-case.
    05 lower-case-alphabet pic a(26).
    05 character-code      pic 999.
    05 loop-counter        pic 99.
procedure division.
control-paragraph.
    perform add-next-letter-paragraph varying loop-counter from 1 by 1
    until loop-counter is greater than 26.
    display lower-case-alphabet upon console.
    stop run.
add-next-letter-paragraph.
    add 97 to loop-counter giving character-code.
    move function char(character-code) to lower-case-alphabet(loop-counter:1).