help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Equivalent of Perl 'join' ?


From: Przemek Klosowski
Subject: Re: Equivalent of Perl 'join' ?
Date: Thu, 16 Dec 2010 14:59:25 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b2 Thunderbird/3.1.6

On 12/16/2010 01:52 PM, Sergei Steshenko wrote:
|     c = {"a", "b", "c"};
|     cstrcat (strcat (c, ";"){:})
|     ans = a;b;c;

Another way:

   c = {"a", "b", "c"};
   sprintf ("%s;", c{:})

jwe
_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave


Not quite:
...
- the trailing ';' is redundant. I.e. Perl 'join' would produce

a;b;c

Good catch. How about this, then:

function res=join(sa,s);
 res=cstrcat (strcat (sa,s){1:end-1},sa{end});
endfunction

join({"a", "b", "c"},';')
ans = a;b;c


reply via email to

[Prev in Thread] Current Thread [Next in Thread]