History of Idiom 219 > diff from v31 to v32
Edit summary for version 32 by shrek:
New Erlang implementation by user [shrek]
New Erlang implementation by user [shrek]
↷
Version 31
2021-08-19, 08:51:47
Version 32
2021-10-01, 14:21:59
Idiom #219 Replace multiple spaces with single space
Create string t from the value of string s with each sequence of spaces replaced by a single space.
Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.
Idiom #219 Replace multiple spaces with single space
Create string t from the value of string s with each sequence of spaces replaced by a single space.
Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.
Extra Keywords
collapse repeatedExtra Keywords
collapse repeatedCode
singleSpace(Text) ->
singleSpace(0, Text).
singleSpace(_, []) -> [];
singleSpace(32, [32 | Rest]) ->
singleSpace(32, Rest);
singleSpace(32, [Ch | Rest]) ->
[Ch] ++ singleSpace(Ch, Rest);
singleSpace(Last, [Ch | Rest]) ->
[Ch] ++ singleSpace(Ch, Rest).
%%singleSpace("this is a text with multiple spaces").
Comments bubble