[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: filesep extension
From: |
Jaroslav Hajek |
Subject: |
Re: filesep extension |
Date: |
Wed, 12 Nov 2008 13:56:10 +0100 |
On Wed, Nov 12, 2008 at 11:37 AM, Michael Goffioul
<address@hidden> wrote:
> On Tue, Nov 11, 2008 at 6:28 PM, Jaroslav Hajek <address@hidden> 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
>
> I like this one. Why do you need to reshape?
If f and str happen to be both vectors, f(str+1) will inherit the
orientation of f rather than str. In all other cases, the reshape
operation does nothing.
> How about commiting?
OK. There is still a correction to be made to make the 3rd output
argument (if present) what one wants it to be - a char array rather
than a logical array.
I'll commit a changeset.
>
> Michael.
>
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- filesep extension, Michael Goffioul, 2008/11/11
- filesep extension, John W. Eaton, 2008/11/11
- Re: filesep extension, Jaroslav Hajek, 2008/11/11
- Re: filesep extension, Michael Goffioul, 2008/11/12
- Re: filesep extension,
Jaroslav Hajek <=
- Re: filesep extension, Michael Goffioul, 2008/11/12
- Re: filesep extension, Jaroslav Hajek, 2008/11/12
- Re: filesep extension, Søren Hauberg, 2008/11/12