Next Previous Contents

4. Intrinsic functions

4.1 zeros, izeros, rzeros, czeros

Intrinsic functions: zeros, izeros, rzeros, czeros

zeros(nx) returns a real zeroed vector of length nx, zeros(nx,ny) returns a zeroed real matrix and so on. You can use it to "dimension" arrays that are indexed later, and to set the initial value to zero. The companion functions izeros and czeros create integer and complex zeroed arrays, respectively. rzeros is a synonym for zeros.

4.2 voids

Intrinsic function: voids

voids(nx) returns an empty vector of Tela objects; voids(nx,ny) returns an empty matrix and so on. A void object can hold any other Tela object in every position, i.e., voids can represent heterogenous collections like lists in lisp, though they are indexed like vectors or arrays.

Voids can be nested. This is a special case of a void holding another void.

4.3 abs

Intrinsic function: abs

abs(x) returns the absolute value of x, which may be of any numeric object. If x is an array, the operation is performed componentwise. If x is a string, an integer vector of the character ASCII codes is returned.

4.4 min, max

Intrinsic functions: min, max

min(x) returns the smallest element of array x, or x itself if x is scalar.

[m,p] = min(x) returns the minimum in m and the minimum position in p.

min(x,y) returns the smaller of x and y. If both are arrays, their dimensions must agree. If one is scalar, it is promoted to array if needed.

min(x,y,...,z) effectively expands to min(x,min(y,...z)...).

The function max works similarly. The arguments may not be complex.

4.5 Nargin, Nargout

Intrinsic functions: Nargin, Nargout

Nargin() returns the number of optional arguments passed to current function. Optional arguments are specified using the ellipsis (...) notation in the formal argument list. You may not use Nargin() in functions whose argument list does not end with an ellipsis.

Nargout() works similarly. For example, the following function f can be called with any number of input/output arguments; it displays the numbers:

    function [...] = f(...) {
        format("`` input args, `` output args.\n",Nargin(),Nargout())
    };

See also: argin

4.6 argin, argout, SetArgOut

Intrinsic functions: argin, argout, SetArgOut

The function argin(n) returns the n-th optional input argument. The first optional argument has n=1. Similarly, argout(n) returns the value of the n-th optional output argument.

SetArgOut(n,x) sets the n-th optional output argument to x.

Please notice that the functions argin, argout and SetArgOut do not count the preceeding 'normal' arguments, but the first optional always has index n=1.

See also: Nargin

4.7 nop

Intrinsic function: nop

nop() generates a 'no-operation' instruction. It is useful (?) for benchmarking purposes. For example,

nop(); nop(); nop(); nop(); nop();

generates five NOP instructions in the flatcode stream.


Next Previous Contents