WeixiangYan/CodeTransOcean huggingface dataset:
Task: Read a file character by character_UTF8





Java: import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Main {

    public static void main(String[] args) throws IOException {
        var reader = new FileReader("input.txt", StandardCharsets.UTF_8);
        while (true) {
            int c = reader.read();
            if (c == -1) break;
            System.out.print(Character.toChars(c));
        }
    }
}
Task: Extract file extension






PHP: $tests = [
    ['input'=>'http://example.com/download.tar.gz', 'expect'=>'.gz'],
    ['input'=>'CharacterModel.3DS', 'expect'=>'.3DS'],
    ['input'=>'.desktop', 'expect'=>'.desktop'],
    ['input'=>'document', 'expect'=>''],
    ['input'=>'document.txt_backup', 'expect'=>''],
    ['input'=>'/etc/pam.d/login', 'expect'=>'']
];

foreach ($tests as $key=>$test) {
    $ext = pathinfo($test['input'], PATHINFO_EXTENSION);


    if (ctype_alnum($ext)) {

        $tests[$key]['actual'] = '.'.$ext;
    } else {
        $tests[$key]['actual'] = '';
    }
}
foreach ($tests as $test) {
    printf("%35s -> %s \n", $test['input'],$test['actual']);
}
Task: Pseudo-random numbers_Middle-square method




Go: package main

import "fmt"

func random(seed int) int {
    return seed * seed / 1e3 % 1e6
}

func main() {
    seed := 675248
    for i := 1; i <= 5; i++ {
        seed = random(seed)
        fmt.Println(seed)
    }
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. MIDDLE-SQUARE.
       
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 STATE.
          03 SEED         PIC 9(6) VALUE 675248.
          03 SQUARE       PIC 9(12).
          03 FILLER       REDEFINES SQUARE.
             05 FILLER    PIC 9(3).
             05 NEXT-SEED PIC 9(6).
             05 FILLER    PIC 9(3).
       
       PROCEDURE DIVISION.
       BEGIN.
           PERFORM SHOW-NUM 5 TIMES.
           STOP RUN.
       
       SHOW-NUM.
           PERFORM MAKE-RANDOM.
           DISPLAY SEED.
       
       MAKE-RANDOM.
           MULTIPLY SEED BY SEED GIVING SQUARE.
           MOVE NEXT-SEED TO SEED.
Task: Use another language to call a function




Go: package main



import "C"
import "unsafe"

func main() {
    C.Run()
}

const msg = "Here am I"


func Query(cbuf *C.char, csiz *C.size_t) C.int {
    if int(*csiz) <= len(msg) {
        return 0
    }
    pbuf := uintptr(unsafe.Pointer(cbuf))
    for i := 0; i < len(msg); i++ {
        *((*byte)(unsafe.Pointer(pbuf))) = msg[i]
        pbuf++
    }
    *((*byte)(unsafe.Pointer(pbuf))) = 0
    *csiz = C.size_t(len(msg) + 1)
    return 1
}






COBOL:        identification division.
       program-id. Query.

       environment division.
       configuration section.
       special-names.
           call-convention 0 is extern.

       repository.
           function all intrinsic.

       data division.
       working-storage section.
       01 query-result.
          05 filler value "Here I am".

       linkage section.
       01 data-reference.
          05 data-buffer   pic x occurs 0 to 8192 times
                                 depending on length-reference.
       01 length-reference usage binary-long.

       procedure division extern using data-reference length-reference.

       if length(query-result) less than or equal to length-reference
                           and length-reference less than 8193 then
           move query-result to data-reference
           move length(query-result) to length-reference
           move 1 to return-code
       end-if

       goback.
       end program Query.
Task: Colour bars_Display




Go: package main

import "github.com/fogleman/gg"

var colors = [8]string{
    "000000", 
    "FF0000", 
    "00FF00", 
    "0000FF", 
    "FF00FF", 
    "00FFFF", 
    "FFFF00", 
    "FFFFFF", 
}

func drawBars(dc *gg.Context) {
    w := float64(dc.Width() / len(colors))
    h := float64(dc.Height())
    for i := range colors {
        dc.SetHexColor(colors[i])
        dc.DrawRectangle(w*float64(i), 0, w, h)
        dc.Fill()
    }
}

func main() {
    dc := gg.NewContext(400, 400)
    drawBars(dc)
    dc.SavePNG("color_bars.png")
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. terminal-colour-bars.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  width           PIC 9(3).
       01  height          PIC 9(3).

       01  interval        PIC 9(3).

       01  colours-area.
           03  colour-values.
               05  FILLER  PIC 9 VALUE 0. 
               05  FILLER  PIC 9 VALUE 4. 
               05  FILLER  PIC 9 VALUE 2. 
               05  FILLER  PIC 9 VALUE 1. 
               05  FILLER  PIC 9 VALUE 5. 
               05  FILLER  PIC 9 VALUE 3. 
               05  FILLER  PIC 9 VALUE 6. 
               05  FILLER  PIC 9 VALUE 7. 

           03  colour-table REDEFINES colour-values.
               05  colours PIC 9 OCCURS 8 TIMES INDEXED BY colour-index.

       01  i               PIC 9(3).
       01  j               PIC 9(3).

       PROCEDURE DIVISION.
           ACCEPT width FROM COLUMNS
           ACCEPT height FROM LINES
           DIVIDE width BY 8 GIVING interval

           PERFORM VARYING i FROM 1 BY 1 UNTIL height < i
               PERFORM VARYING j FROM 1 BY 1 UNTIL width < j
                  COMPUTE colour-index = (j / interval) + 1
                  
                  IF 8 < colour-index
                      SET colour-index TO 8
                  END-IF

                  
                  
                  
                  DISPLAY SPACE AT LINE i COLUMN j
                      WITH BACKGROUND-COLOR colours (colour-index)
               END-PERFORM
           END-PERFORM

           ACCEPT i 

           GOBACK
           .
Task: Enforced immutability




Go: package main

func main() {
    s := "immutable"
    s[0] = 'a'
}






COBOL: ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
    SYMBOLIC CHARACTERS NUL IS 0, TAB IS 9.
Task: Strange numbers




Go: package main

import "fmt"

func isPrime(n int) bool {
    if n < 0 {
        n = -n
    }
    return n == 2 || n == 3 || n == 5 || n == 7
}

func main() {
    count := 0
    var d []int
    fmt.Println("Strange numbers in the open interval (100, 500) are:\n")
    for i := 101; i < 500; i++ {
        d = d[:0]
        j := i
        for j > 0 {
            d = append(d, j%10)
            j /= 10
        }
        if isPrime(d[0]-d[1]) && isPrime(d[1]-d[2]) {
            fmt.Printf("%d ", i)
            count++
            if count%10 == 0 {
                fmt.Println()
            }
        }
    }
    if count%10 != 0 {
        fmt.Println()
    }
    fmt.Printf("\n%d strange numbers in all.\n", count)
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. STRANGE-NUMBERS.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 COMPUTATION.
           02 NUM           PIC 999.
           02 DIGITS        REDEFINES NUM PIC 9 OCCURS 3 TIMES.
           02 DIGIT-PRIME   PIC 9.
              88 PRIME      VALUES 2 3 5 7.
           02 CUR-DIGIT     PIC 9.
        01 OUTPUT-FORMAT.
           02 N-OUT         PIC ZZ9.
        PROCEDURE DIVISION.
        BEGIN.
            PERFORM STRANGE-TEST
                VARYING NUM FROM 100 BY 1
                UNTIL NUM IS GREATER THAN 500.
            STOP RUN.
        
        STRANGE-TEST SECTION.
        BEGIN.
            SET CUR-DIGIT TO 1.
        STEP.   
            IF DIGITS(CUR-DIGIT) IS LESS THAN DIGITS(CUR-DIGIT + 1)
                SUBTRACT DIGITS(CUR-DIGIT + 1) FROM DIGITS(CUR-DIGIT) 
                    GIVING DIGIT-PRIME
            ELSE
                SUBTRACT DIGITS(CUR-DIGIT) FROM DIGITS(CUR-DIGIT + 1)
                    GIVING DIGIT-PRIME.
            IF PRIME NEXT SENTENCE ELSE GO TO DONE.
            ADD 1 TO CUR-DIGIT.
            IF CUR-DIGIT IS LESS THAN 3 GO TO STEP.
            MOVE NUM TO N-OUT.
            DISPLAY N-OUT.
        DONE. EXIT.
Task: Create an object at a given address




Go: package main

import(
	"fmt"
	"unsafe"
	"reflect"
)

func pointer() {
	fmt.Printf("Pointer:\n")

	
	
	
	
	var i int
	p := &i

	fmt.Printf("Before:\n\t%v: %v, %v\n", p, *p, i)

	*p = 3

	fmt.Printf("After:\n\t%v: %v, %v\n", p, *p, i)
}

func slice() {
	fmt.Printf("Slice:\n")

	var a [10]byte

	
	
	
	
	
	var h reflect.SliceHeader
	h.Data = uintptr(unsafe.Pointer(&a)) 
	h.Len = len(a)
	h.Cap = len(a)

	
	s := *(*[]byte)(unsafe.Pointer(&h))

	fmt.Printf("Before:\n\ts: %v\n\ta: %v\n", s, a)

	
	
	copy(s, "A string.")

	fmt.Printf("After:\n\ts: %v\n\ta: %v\n", s, a)
}

func main() {
	pointer()
	fmt.Println()

	slice()
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. object-address-test.
       DATA DIVISION.
       LOCAL-STORAGE SECTION.
       01 int-space.
          05 val PICTURE 9(5) VALUE 12345.
       01 addr BASED.
          05 val PICTURE 9(5) VALUE ZERO.
       01 point USAGE POINTER.
       PROCEDURE DIVISION.
         DISPLAY val OF int-space END-DISPLAY
         SET point TO ADDRESS OF int-space
         DISPLAY point END-DISPLAY
         SET ADDRESS OF addr TO point
         DISPLAY val OF addr END-DISPLAY
         MOVE 65535 TO val OF addr
         DISPLAY val OF addr END-DISPLAY
         DISPLAY val OF int-space END-DISPLAY
         STOP RUN.
       END PROGRAM object-address-test.
Task: Hofstadter Q sequence




Go: package main

import "fmt"

var m map[int]int

func initMap() {
    m = make(map[int]int)
    m[1] = 1
    m[2] = 1
}

func q(n int) (r int) {
    if r = m[n]; r == 0 {
        r = q(n-q(n-1)) + q(n-q(n-2))
        m[n] = r
    }
    return
}

func main() {
    initMap()
    
    for n := 1; n <= 10; n++ {
        showQ(n)
    }
    
    showQ(1000)
    
    count, p := 0, 1
    for n := 2; n <= 1e5; n++ {
        qn := q(n)
        if qn < p {
            count++
        }
        p = qn
    }
    fmt.Println("count:", count)
    
    initMap()
    showQ(1e6)
}

func showQ(n int) {
    fmt.Printf("Q(%d) = %d\n", n, q(n))
}






COBOL:         IDENTIFICATION DIVISION.
        PROGRAM-ID. Q-SEQ.
        
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 SEQ.
           02 Q         PIC 9(3) OCCURS 1000 TIMES.
           02 Q-TMP1    PIC 9(3).
           02 Q-TMP2    PIC 9(3).
           02 N         PIC 9(4).
        01 DISPLAYING.
           02 ITEM      PIC Z(3).
           02 IX        PIC Z(4).
            
        PROCEDURE DIVISION.
        MAIN-PROGRAM.    
            PERFORM GENERATE-SEQUENCE.
            PERFORM SHOW-ITEM
                VARYING N FROM 1 BY 1 
                UNTIL N IS GREATER THAN 10.
            SET N TO 1000.
            PERFORM SHOW-ITEM.
            STOP RUN.
        
        GENERATE-SEQUENCE.
            SET Q(1) TO 1.
            SET Q(2) TO 1.            
            PERFORM GENERATE-ITEM 
                VARYING N FROM 3 BY 1
                UNTIL N IS GREATER THAN 1000.
        
        GENERATE-ITEM.
            COMPUTE Q-TMP1 = N - Q(N - 1).
            COMPUTE Q-TMP2 = N - Q(N - 2).
            COMPUTE Q(N) = Q(Q-TMP1) + Q(Q-TMP2).
                        
        SHOW-ITEM.
            MOVE N TO IX.
            MOVE Q(N) TO ITEM.
            DISPLAY 'Q(' IX ') = ' ITEM.
Task: Count occurrences of a substring




Go: package main
import (
        "fmt"
        "strings"
)

func main() {
        fmt.Println(strings.Count("the three truths", "th")) 
        fmt.Println(strings.Count("ababababab", "abab"))     
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. testing.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  occurrences             PIC 99.

       PROCEDURE DIVISION.
           INSPECT "the three truths" TALLYING occurrences FOR ALL "th"
           DISPLAY occurrences

           MOVE 0 TO occurrences
           INSPECT "ababababab" TALLYING occurrences FOR ALL "abab"
           DISPLAY occurrences
           
           MOVE 0 TO occurrences
           INSPECT "abaabba*bbaba*bbab" TALLYING occurrences
               FOR ALL "a*b"
           DISPLAY occurrences

           GOBACK
           .
Task: Hickerson series of almost integers




Go: package main

import (
    "fmt"
    "math/big"
)

func main() {
    ln2, _ := new(big.Rat).SetString("0.6931471805599453094172")
    h := big.NewRat(1, 2)
    h.Quo(h, ln2)
    var f big.Rat
    var w big.Int
    for i := int64(1); i <= 17; i++ {
        h.Quo(h.Mul(h, f.SetInt64(i)), ln2)
        w.Quo(h.Num(), h.Denom())
        f.Sub(h, f.SetInt(&w))
        y, _ := f.Float64()
        d := fmt.Sprintf("%.3f", y)
        fmt.Printf("n: %2d  h: %18d%s  Nearly integer: %t\n",
            i, &w, d[1:], d[2] == '0' || d[2] == '9')
    }
}






COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. hickerson-series.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
REPOSITORY.
    FUNCTION ALL INTRINSIC
    .
DATA DIVISION.
WORKING-STORAGE SECTION.
01  n                                   PIC 99 COMP.

01  h                                   PIC Z(19)9.9(10).

01  First-Decimal-Digit-Pos             CONSTANT 22.

PROCEDURE DIVISION.
    PERFORM VARYING n FROM 0 BY 1 UNTIL n > 17
        COMPUTE h = FACTORIAL(n) / (2 * LOG(2) ** (n + 1))
        DISPLAY "h(" n ") = " h " which is " NO ADVANCING
        IF h (First-Decimal-Digit-Pos:1) = "0" OR "9"
            DISPLAY "an almost integer."
        ELSE
            DISPLAY "not an almost integer."
        END-IF
    END-PERFORM
    .
END PROGRAM hickerson-series.
Task: Sorting algorithms_Stooge sort




Go: package main

import "fmt"

var a = []int{170, 45, 75, -90, -802, 24, 2, 66}

func main() {
    fmt.Println("before:", a)
    stoogesort(a)
    fmt.Println("after: ", a)
    fmt.Println("nyuk nyuk nyuk")
}

func stoogesort(a []int) {
    last := len(a) - 1
    if a[last] < a[0] {
        a[0], a[last] = a[last], a[0]
    }
    if last > 1 {
        t := len(a) / 3
        stoogesort(a[:len(a)-t])
        stoogesort(a[t:])
        stoogesort(a[:len(a)-t])
    }
}






COBOL:        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. stooge-sort-test.

DATA DIVISION.
WORKING-STORAGE SECTION.
01  Arr-Len                             CONSTANT 7.

01  arr-area                            VALUE "00004001000020000005000230000000000".
    03  arr-elt                         PIC 9(5) OCCURS Arr-Len TIMES
                                        INDEXED BY arr-idx.

PROCEDURE DIVISION.
    DISPLAY "Unsorted: " NO ADVANCING
    PERFORM VARYING arr-idx FROM 1 BY 1 UNTIL Arr-Len < arr-idx
        DISPLAY arr-elt (arr-idx) " " NO ADVANCING
    END-PERFORM
    DISPLAY SPACE

    CALL "stooge-sort" USING arr-area, OMITTED, OMITTED

    DISPLAY "Sorted:   " NO ADVANCING
    PERFORM VARYING arr-idx FROM 1 BY 1 UNTIL Arr-Len < arr-idx
        DISPLAY arr-elt (arr-idx) " " NO ADVANCING
    END-PERFORM
    DISPLAY SPACE
    .
END PROGRAM stooge-sort-test.
    

IDENTIFICATION DIVISION.
PROGRAM-ID. stooge-sort RECURSIVE.

DATA DIVISION.
LOCAL-STORAGE SECTION.
01  Arr-Len                             CONSTANT 7.

01  i                                   PIC 99 COMP.
01  j                                   PIC 99 COMP.

01  temp                                PIC 9(5).

01  t                                   PIC 99 COMP.

LINKAGE SECTION.
01  arr-area.
    03  arr-elt                         PIC 9(5) OCCURS Arr-Len TIMES.

01  i-val                               PIC 99 COMP.
01  j-val                               PIC 99 COMP.

PROCEDURE DIVISION USING arr-area, OPTIONAL i-val, OPTIONAL j-val.
    IF i-val IS OMITTED
        MOVE 1 TO i
    ELSE
        MOVE i-val TO i
    END-IF
    IF j-val IS OMITTED
        MOVE Arr-Len TO j
    ELSE
        MOVE j-val TO j
    END-IF
    
    IF arr-elt (j) < arr-elt (i)
        MOVE arr-elt (i) TO temp
        MOVE arr-elt (j) TO arr-elt (i)
        MOVE temp TO arr-elt (j)
    END-IF   
    
    IF j - i + 1 >= 3
        COMPUTE t = (j - i + 1) / 3
        SUBTRACT t FROM j
        CALL "stooge-sort" USING arr-area, CONTENT i, j
        ADD t TO i, j
        CALL "stooge-sort" USING arr-area, CONTENT i, j
        SUBTRACT t FROM i, j
        CALL "stooge-sort" USING arr-area, CONTENT i, j
    END-IF
    .
END PROGRAM stooge-sort.
Task: Digit fifth powers




Go: package main

import (
    "fmt"
    "rcu"
)

func main() {
    
    dp5 := [10]int{0, 1}
    for i := 2; i < 10; i++ {
        ii := i * i
        dp5[i] = ii * ii * i
    }
    fmt.Println("The sum of all numbers that can be written as the sum of the 5th powers of their digits is:")
    limit := dp5[9] * 6
    sum := 0
    for i := 2; i <= limit; i++ {
        digits := rcu.Digits(i, 10)
        totalDp := 0
        for _, d := range digits {
            totalDp += dp5[d]
        }
        if totalDp == i {
            if sum > 0 {
                fmt.Printf(" + %d", i)
            } else {
                fmt.Print(i)
            }
            sum += i
        }
    }
    fmt.Printf(" = %d\n", sum)
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. DIGIT-FIFTH-POWER.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 VARIABLES.
          03 CANDIDATE          PIC 9(6).
          03 MAXIMUM            PIC 9(6).
          03 DIGITS             PIC 9 OCCURS 6 TIMES,
                                REDEFINES CANDIDATE.
          03 DIGIT              PIC 9.
          03 POWER-SUM          PIC 9(6).
          03 TOTAL              PIC 9(6).

       01 OUT-FORMAT.
          03 OUT-NUM            PIC Z(5)9.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE ZERO TO TOTAL.
           COMPUTE MAXIMUM = 9 ** 5 * 6.
           PERFORM TEST-NUMBER
               VARYING CANDIDATE FROM 2 BY 1
               UNTIL CANDIDATE IS GREATER THAN MAXIMUM.
           DISPLAY '------ +'.
           DISPLAY TOTAL.
           STOP RUN.

       TEST-NUMBER.
           MOVE ZERO TO POWER-SUM.
           PERFORM ADD-DIGIT-POWER
               VARYING DIGIT FROM 1 BY 1
               UNTIL DIGIT IS GREATER THAN 6.
           IF POWER-SUM IS EQUAL TO CANDIDATE,
               MOVE CANDIDATE TO OUT-NUM,
               DISPLAY OUT-NUM,
               ADD CANDIDATE TO TOTAL.
       
       ADD-DIGIT-POWER.
           COMPUTE POWER-SUM = POWER-SUM + DIGITS(DIGIT) ** 5.
Task: McNuggets problem




Go: package main

import "fmt"

func mcnugget(limit int) {
    sv := make([]bool, limit+1) 
    for s := 0; s <= limit; s += 6 {
        for n := s; n <= limit; n += 9 {
            for t := n; t <= limit; t += 20 {
                sv[t] = true
            }
        }
    }
    for i := limit; i >= 0; i-- {
        if !sv[i] {
            fmt.Println("Maximum non-McNuggets number is", i)
            return
        }
    }
}

func main() {
    mcnugget(100)
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.  MCNUGGETS.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 NUGGETS.
          03 NUGGET-FLAGS     PIC X OCCURS 100 TIMES.
             88 IS-NUGGET     VALUE 'X'.

       01 A                   PIC 999.
       01 B                   PIC 999.
       01 C                   PIC 999.

       PROCEDURE DIVISION.
       BEGIN.
           MOVE SPACES TO NUGGETS.
           PERFORM A-LOOP VARYING A FROM 0 BY 6
               UNTIL A IS GREATER THAN 100.
           MOVE 100 TO A.

       FIND-LARGEST.
           IF IS-NUGGET(A), SUBTRACT 1 FROM A, GO TO FIND-LARGEST.
           DISPLAY 'Largest non-McNugget number: ', A.
           STOP RUN.
 
       A-LOOP.
           PERFORM B-LOOP VARYING B FROM A BY 9
               UNTIL B IS GREATER THAN 100.

       B-LOOP.
           PERFORM C-LOOP VARYING C FROM B BY 20
               UNTIL C IS GREATER THAN 100.
 
       C-LOOP.
           IF C IS NOT EQUAL TO ZERO, MOVE 'X' TO NUGGET-FLAGS(C).
Task: Idiomatically determine all the lowercase and uppercase letters




Go: package main

import (
	"fmt"
	"unicode"
)

const (
	lcASCII = "abcdefghijklmnopqrstuvwxyz"
	ucASCII = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

func main() {
	fmt.Println("ASCII lower case:")
	fmt.Println(lcASCII)
	for l := 'a'; l <= 'z'; l++ {
		fmt.Print(string(l))
	}
	fmt.Println()

	fmt.Println("\nASCII upper case:")
	fmt.Println(ucASCII)
	for l := 'A'; l <= 'Z'; l++ {
		fmt.Print(string(l))
	}
	fmt.Println()

	fmt.Println("\nUnicode version " + unicode.Version)
	showRange16("Lower case 16-bit code points:", unicode.Lower.R16)
	showRange32("Lower case 32-bit code points:", unicode.Lower.R32)
	showRange16("Upper case 16-bit code points:", unicode.Upper.R16)
	showRange32("Upper case 32-bit code points:", unicode.Upper.R32)
}

func showRange16(hdr string, rList []unicode.Range16) {
	fmt.Print("\n", hdr, "\n")
	fmt.Printf("%d ranges:\n", len(rList))
	for _, rng := range rList {
		fmt.Printf("%U: ", rng.Lo)
		for r := rng.Lo; r <= rng.Hi; r += rng.Stride {
			fmt.Printf("%c", r)
		}
		fmt.Println()
	}
}

func showRange32(hdr string, rList []unicode.Range32) {
	fmt.Print("\n", hdr, "\n")
	fmt.Printf("%d ranges:\n", len(rList))
	for _, rng := range rList {
		fmt.Printf("%U: ", rng.Lo)
		for r := rng.Lo; r <= rng.Hi; r += rng.Stride {
			fmt.Printf("%c", r)
		}
		fmt.Println()
	}
}






COBOL:        identification division.
       program-id. determine.

       environment division.
       configuration section.
       repository.
           function all intrinsic.

       data division.
       working-storage section.
       01 tx pic x.
       01 lower-8bit pic x(256).
       01 upper-8bit pic x(256).

      
      
      

       01 low-slide usage index.
       01 high-slide usage index.

       procedure division.
       determining.

      
       set low-slide to 0
       set high-slide to 0
       perform varying tally from 1 by 1 until tally > 256
           move char(tally) to tx
           if tx is alphabetic-lower then
               set low-slide up by 1
               move tx to lower-8bit(low-slide:1)
           end-if
           if tx is alphabetic-upper then
               set high-slide up by 1
               move tx to upper-8bit(high-slide:1)
           end-if
       end-perform
       if low-slide equal 0 then
           display "no lower case letters detected" upon syserr
       else
           display lower-8bit(1:low-slide)
       end-if
       if high-slide equal 0 then
           display "no upper case letters detected" upon syserr
       else
           display upper-8bit(1:high-slide)        
       end-if

      
      

      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

       goback.
       end program determine.