How to resolve the algorithm Tokenize a string step by step in the PL/I programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Tokenize a string step by step in the PL/I programming language
Table of Contents
Problem Statement
Separate the string "Hello,How,Are,You,Today" by commas into an array (or list) so that each element of it stores a different word. Display the words to the 'user', in the simplest manner possible, separated by a period. To simplify, you may display a trailing period.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Tokenize a string step by step in the PL/I programming language
Source code in the pl/i programming language
tok: Proc Options(main);
declare s character (100) initial ('Hello,How,Are,You,Today');
declare n fixed binary (31);
n = tally(s, ',')+1;
begin;
declare table(n) character (50) varying;
declare c character (1);
declare (i, k) fixed binary (31);
table = ''; k = 1;
do i = 1 to length(s);
c = substr(s, i, 1);
if c = ',' then k = k + 1;
else table(k) = table(k) || c;
end;
/* display the table */
table = table || '.';
put skip list (string(table));
end;
end;
You may also check:How to resolve the algorithm Playing cards step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Remove lines from a file step by step in the Fortran programming language
You may also check:How to resolve the algorithm Combinations with repetitions step by step in the TXR programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the F# programming language