6.4 Comma Separated Lists

Comma separated lists 2 are the basic argument type to all Octave functions - both for input and return arguments. In the example

max (a, b)

a, b’ is a comma separated list. Comma separated lists can appear on both the right and left hand side of an assignment. For example

x = [1 0 1 0 0 1 1; 0 0 0 0 0 0 7];
[i, j] = find (x, 2, "last");

Here, ‘x, 2, "last"’ is a comma separated list constituting the input arguments of find. find returns a comma separated list of output arguments which is assigned element by element to the comma separated list ‘i, j’.

Another example of where comma separated lists are used is in the creation of a new array with [] (see Matrices) or the creation of a cell array with {} (see Basic Usage of Cell Arrays). In the expressions

a = [1, 2, 3, 4];
c = {4, 5, 6, 7};

both ‘1, 2, 3, 4’ and ‘4, 5, 6, 7’ are comma separated lists.

Comma separated lists cannot be directly manipulated by the user. However, both structure arrays and cell arrays can be converted into comma separated lists, and thus used in place of explicitly written comma separated lists. This feature is useful in many ways, as will be shown in the following subsections.

Footnotes

(2)

Comma-separated lists are also sometimes informally referred to as cs-lists.

© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Comma-Separated-Lists.html