Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.Merging adjacent strings

5 views
Skip to first unread message

Robert L.

unread,
Jan 21, 2017, 12:16:33 PM1/21/17
to
> (merge-strings '("1" "2" 3 4 "5" "6" 7 8 "9"))
> ===>
> ("12" 3 4 "56" 7 8 "9")

Ruby:

def merge_strings array
array.chunk{|x| x.is_a? String}.flat_map{|bool,xs|
bool ? xs.join : xs}
end

merge_strings ["1","2",3,4,"5","6","7",8,"9"]
===>
["12", 3, 4, "567", 8, "9"]

In Forth?

--
The former leader of the National Front Jean-Marie Le Pen was fined 30,000
euros for exposing the Jews' Holocaust gas chamber hoax.
infostormer.com/jean-marie-le-pen-fined-30000-euros-for-exposing-jewish-holocaust-gas-chamber-hoax
0 new messages