help-octave
[Top][All Lists]
Advanced

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

Re: Equivalent of Perl 'join' ?


From: Sergei Steshenko
Subject: Re: Equivalent of Perl 'join' ?
Date: Thu, 16 Dec 2010 12:41:45 -0800 (PST)


--- On Thu, 12/16/10, Przemek Klosowski <address@hidden> wrote:

> From: Przemek Klosowski <address@hidden>
> Subject: Re: Equivalent of Perl 'join' ?
> To: "address@hidden" <address@hidden>
> Date: Thursday, December 16, 2010, 11:59 AM
> 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

Well, in Perl the order of arguments is reverse :) .

Regards,
  Sergei.


      



reply via email to

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