A bit rushed, but the following CONCAT seems to work.

concat: func [values [block!] sep [string! char!] /local string] [
    string: copy ""
    forall values [insert insert tail string sep first values]
    remove/part string length? sep
]

>> concat [] ", "
== ""
>> concat [1] ", "
== "1"
>> concat [1 "2" <3>] ", "
== "1, 2, <3>"
>> concat [1 "2" <3> %4 #5] ", "
== "1, 2, <3>, 4, 5"
>> concat ["a" "b" "1" "2"] "-"
== "a-b-1-2"
>> concat ["a" "b" "1" "2"] ", "
== "a, b, 1, 2"

HTH,

Christian



-------- Original-Nachricht --------
> Von: "Şemseddin Moldibi [ Bircom ]" <[email protected]>
> Betreff: [REBOL] joining strings

> What is the best way to join a block into a string with a separator?
> I prefer not to use loop if it is possible.

> b: ["a" "b" "1" "2"]
> t: concat b "-"

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to