How to resolve the algorithm Split a character string based on change of character step by step in the BaCon programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Split a character string based on change of character step by step in the BaCon programming language

Table of Contents

Problem Statement

Split a (character) string into comma (plus a blank) delimited strings based on a change of character   (left to right). Show the output here   (use the 1st example below).

Blanks should be treated as any other character   (except they are problematic to display clearly).   The same applies to commas.

For instance, the string: should be split and show:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Split a character string based on change of character step by step in the BaCon programming language

Source code in the bacon programming language

txt$ = "gHHH5YY++///\\"

c$ = LEFT$(txt$, 1)

FOR x = 1 TO LEN(txt$)
    d$ = MID$(txt$, x, 1)
    IF d$ <> c$ THEN
        PRINT ", ";
        c$ = d$
    END IF
    PRINT d$;
NEXT

  

You may also check:How to resolve the algorithm Forward difference step by step in the Quackery programming language
You may also check:How to resolve the algorithm Church numerals step by step in the OCaml programming language
You may also check:How to resolve the algorithm Array length step by step in the Diego programming language
You may also check:How to resolve the algorithm System time step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Square-free integers step by step in the AWK programming language