Logo

Programming-Idioms

History of Idiom 41 > diff from v55 to v56

Edit summary for version 56 by Roie8:
New Cobol implementation by user [Roie8]

Version 55

2019-09-27, 08:49:10

Version 56

2019-09-27, 20:41:06

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Illustration

Idiom #41 Reverse a string

Create string t containing the same characters as string s, in reverse order.
Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

Illustration
Code
IDENTIFICATION DIVISION.
PROGRAM-ID. reverse string.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 s			PIC x(4) VALUE 'ROIE'.
01 t			PIC x(4).
PROCEDURE DIVISION.
    MOVE FUNCTION REVERSE(s) TO t
STOP RUN.