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

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Split a character string based on change of character step by step in the J 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 J programming language

Source code in the j programming language

splitChars=: (1 ,~ 2 ~:/\ ]) <;.2 ]
delimitChars=: ', ' joinstring splitChars


   delimitChars 'gHHH5YY++///\'
g, HHH, 5, YY, ++, ///, \


  

You may also check:How to resolve the algorithm Harshad or Niven series step by step in the Scala programming language
You may also check:How to resolve the algorithm Averages/Pythagorean means step by step in the zkl programming language
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the SPL programming language
You may also check:How to resolve the algorithm Ternary logic step by step in the Forth programming language
You may also check:How to resolve the algorithm Yin and yang step by step in the Evaldraw programming language