Logo

Programming-Idioms

History of Idiom 41 > diff from v56 to v57

Edit summary for version 57 by Roie8:
[Cobol] fix

Version 56

2019-09-27, 20:41:06

Version 57

2019-09-27, 20:51:02

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.
Code
IDENTIFICATION DIVISION.
PROGRAM-ID. reverse string.
PROCEDURE DIVISION.
    MOVE FUNCTION REVERSE(s) TO t
STOP RUN.