[Top][All Lists]

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

Re: Strange syntax

From: Juan Pablo Carbajal
Subject: Re: Strange syntax
Date: Wed, 28 Nov 2012 12:15:38 +0100

On Wed, Nov 28, 2012 at 11:55 AM, bigmealy
<address@hidden> wrote:
> T = __delaunayn__ (pts, varargin{:});

__delaunayn__ is an private function and are usssually not doucmented.
In this case it doesn't matter casue the .m fuction is just a wrapper
for it, so the help in the .m function is describing the private

Now, there is not such a thing as curly braces modifier. The curly
braces are used to index (i.e. access the elements) of cells, which
are a type of general container in Octave (like vector from the C++
STL). Wehn a function can take an undefined number of input arguments
we use the varargin (variable input arguments) in its signature. The
variable varargin, inside a function, contains the arguments that were
passed to the function. For example, assme that a function foo was
defined with "function foo (x,varargin)" then

foo (1)

will have x==1 and varargin empty inside foo.

foo (1,"bar",3)

will have x==1 and varargin == {"bar", 3} inside foo.

When a cell is indexed with the colon operator ":", it gives all its
elements. Assume that foo as defined before calls, in its body, a
function bar with signature "function bar (x,y)". The call

bar (varargin{:})

is equivalent to

bar ("bar", 3)

To know more about cells read the Octave manual.


reply via email to

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