Split a character string based on change of character: Difference between revisions

Content added Content deleted
m (moved ANSI BASIC to it's proper place alphabetically.)
Line 22: Line 22:
should be split and show:
should be split and show:
<big><big> g, HHH, 5, YY, ++, ///, \ </big></big>
<big><big> g, HHH, 5, YY, ++, ///, \ </big></big>

<br><br>
<br><br>

=={{header|Ada}}==
=={{header|Ada}}==
<lang ada>
<lang ada>
Line 80: Line 80:
g, HHH, 5, YY, ++, ///, \
g, HHH, 5, YY, ++, ///, \
</pre>
</pre>

=={{header|ANSI BASIC}}==
<lang ansibasic>REM >split
DECLARE EXTERNAL FUNCTION FN_split$

PRINT FN_split$( "gHHH5YY++///\" )
END

EXTERNAL FUNCTION FN_split$( s$ )
LET c$ = s$(1:1)
LET split$ = ""
FOR i = 1 TO LEN(s$)
LET d$ = s$(i:i)
IF d$ <> c$ THEN
LET split$ = split$ & ", "
LET c$ = d$
END IF
LET split$ = split$ & d$
NEXT i
LET FN_split$ = split$
END FUNCTION</lang>
{{out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>


=={{header|AppleScript}}==
=={{header|AppleScript}}==
Line 202: Line 225:
{{Out}}
{{Out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
<pre>g, HHH, 5, YY, ++, ///, \</pre>

=={{header|AWK}}==
=={{header|AWK}}==
<lang AWK>
<lang AWK>
Line 266: Line 290:
NEXT
NEXT
= split$</lang>
= split$</lang>
{{out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>

=={{header|ANSI BASIC}}==
<lang ansibasic>REM >split
DECLARE EXTERNAL FUNCTION FN_split$

PRINT FN_split$( "gHHH5YY++///\" )
END

EXTERNAL FUNCTION FN_split$( s$ )
LET c$ = s$(1:1)
LET split$ = ""
FOR i = 1 TO LEN(s$)
LET d$ = s$(i:i)
IF d$ <> c$ THEN
LET split$ = split$ & ", "
LET c$ = d$
END IF
LET split$ = split$ & d$
NEXT i
LET FN_split$ = split$
END FUNCTION</lang>
{{out}}
{{out}}
<pre>g, HHH, 5, YY, ++, ///, \</pre>
<pre>g, HHH, 5, YY, ++, ///, \</pre>