Hi all.

`Is it possible to have a list of lists in formula type questions? That is, two-dimensional lists`

Example:

List = [ [1,2,3] , [1,2,3] , [1,2,3] ];

Thanks

Hi all.

`Is it possible to have a list of lists in formula type questions? That is, two-dimensional lists`

Example:

List = [ [1,2,3] , [1,2,3] , [1,2,3] ];

Thanks

Hello Miguel,

No, you cannot have a list of lists. For example, you cannot have

A = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]

However, you can use

A = [1,2,3,4,5,6,7,8,9,10,11,12]

and get the same results.

Consider matrix A of dimension m × n = 3 × 4

\(A = \begin{bmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ \end{bmatrix} = \begin{bmatrix} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ 9 & 10 & 11 & 12 \\ \end{bmatrix}\)

The rows of \(A\) are

\( \begin{bmatrix} 1 & 2 & 3 & 4 \end{bmatrix}\)

\( \begin{bmatrix} 5 & 6 & 7 & 8 \end{bmatrix}\)

\( \begin{bmatrix} 9 & 10 & 11 & 12 \end{bmatrix}\)

In the Formulas question, we can write

A1 = [1,2,3,4]; A2 = [5,6,7,8]; A3 = [9,10,11,12]; A = concat(A1,A2,A3); # =[1,2,3,4,5,6,7,8,9,10,11,12]

To select the element \(a_{ij}\) of matrix \(A\), we can use A[k] where the index k is simply defined as follows

k = (i-1)*n + (j-1);

where n is the number of columns of the matrix, and i and j are respectively the ith row and jth column of element \(a_{ij}\). If i and j are counted from zero, k is defined as

k = i*n + j;

You can try the following example at **https://moodleformulas.org/course/view.php?id=102§ion=7 ↗**.

ok Dominique, I appreciate your help. I worked the question as you indicate it to me.

I take the opportunity to ask. Is there a way to get the i character from a string? For instance:

List = ["Hi", "have a", "nice", "day"];

Char = List[1][2]; # I hope "v"