help-octave
[Top][All Lists]
Advanced

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

Re: Equivalent of Perl 'join' ?


From: CdeMills
Subject: Re: Equivalent of Perl 'join' ?
Date: Thu, 16 Dec 2010 13:08:22 -0800 (PST)


bpabbott wrote:
> 
> 
>  
> I like John's solution. Assuming perl does not trim the spaces for the
> listed strings, and the last separator is to be removed ...
> 
>       join = @(expr,list) sprintf (sprintf ("%s%s", "%s", expr),
> list{:})(1:end-1);
> 
> 

To be compatible with Perl, i.e. no trimming of 'expr' and expr not included
after the last element:
join=@(expr, list)  sprintf("%s%s", sprintf(sprintf ("%s%s", "%s", expr),
list{1:end-1}), list{end});

A big one-liner, but still an one-liner.

Regards

Pascal

-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Equivalent-of-Perl-join-tp3090590p3091652.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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