octave-maintainers
[Top][All Lists]
Advanced

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

Re: filesep extension


From: Jaroslav Hajek
Subject: Re: filesep extension
Date: Tue, 11 Nov 2008 20:58:09 +0100

On Tue, Nov 11, 2008 at 8:48 PM, John W. Eaton <address@hidden> wrote:
> On 11-Nov-2008, Jaroslav Hajek wrote:
>
> | It seems I tried an ugly trick that wouldn't work. So here's a
> | hopefully working version:
> |
> |  function varargout = strchr (str, chars, varargin)
> |  if (nargin < 2 || ! ischar (str) || ! ischar (chars))
> |    print_usage ();
> |  endif
> |  f = false (1, 256);
> |  f(chars+1) = true;
> |  varargout = cell (1, nargout);
> |  varagout{1} = [];
> |  [varargout{:}] = find (reshape (f(str+1), size (str)), varargin{:});
> | endfunction
>
> What are you trying to do with
>
>  varargout = cell (1, nargout);
>  varagout{1} = [];
>
> ?  Why is the second statement needed?
>

To force varargout to have at least one element. If strchr is called
with 0 arguments,
we should still call find with a single output arg and return it.

> jwe
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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