help-octave
[Top][All Lists]
Advanced

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

Re: Synonym


From: Doug Stewart
Subject: Re: Synonym
Date: Wed, 8 Apr 2020 08:37:32 -0400



On Wed, Apr 8, 2020 at 8:28 AM Richardson, Anthony <address@hidden> wrote:

 

From: Doug Stewart
To: Ian McCallion <address@hidden>
Cc: Help GNU Octave <address@hidden>
Subject: Re: Synonym

 

>> On Wed, Apr 8, 2020 at 7:35 AM Ian McCallion <address@hidden> wrote:

>> What is the right syntax for providing a function which does nothing except call another function with the same parameters and returns the same values back.

>> 

>> The function below passes the parameters through, but getting returned values back does not work. I've tried various incantations without success

>> 

>>   function [varargout] = short(varargin)

>>       varargout = verylongame(varargin){:})

>>    endfunction

>> 

>> Cheers... Ian

>> 

> this seems to work!

>
> function [varargout2] = short(varargin)
>       varargout = verylongname(varargin{:})
>       varargout2=varargout(:)
>    endfunction
>

> 

> --

> DAS

 

Doug,

I could not get that to work when multiple output arguments are requested.  My attempt is below.  It’s kind of ugly, maybe someone can come up with a nicer method.

 

Tony

 

function varargout = short(varargin)

  usv = nthargout ([1:nargout()], @short, varargin{:});

   if isa(usv, "cell")

      for i = 1:nargout

        varargout{i} = usv{i};

      endfor

    else

      varargout{1} = usv;

    endif 

endfunction

 

 

 

 

 

 

Here is my testing code that worked:

a=1;
 function q=verylongname(x)
   q(1)={'hi'}
   q(2)={'to you'}
 endfunction
 
 
 
 function [varargout2] = short(varargin)
       varargout = verylongname(varargin{:})
       varargout2=varargout(:)
    endfunction
   
    varargout1=short()
  

put that in an M file and run it.
  

--
DASCertificate for 206392


reply via email to

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