Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: joining strings

From: Christian::Ensel::gmx::de at: 27-Jul-2009 17:44

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 ]" <semseddinm-bircom.com> > 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