Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

Table of values (table)

Build a list by evaluating an expression over one or more ranges.

How to write it

table(expr, k = a..b)

A list with one element for each value of the index.

expr
Any expression: a number, a formula, a list or a matrix. Takes an expression.
k = a..b
The index and its bounds. Takes a variable with its range.

table(expr, i = a..b, j = a..b)

A list of lists: a matrix when the ranges are numbers.

expr
Any expression: a number, a formula, a list or a matrix. Takes an expression.
i = a..b
The first index and its range. Takes a variable with its range.
j = a..b
The second index and its range. Takes a variable with its range.

Examples

  • table⁡(k2,k=1…5)=[1,4,9,16,25]\displaystyle \operatorname{table}(k^{2}, k = 1 \ldots 5) = \left[ 1, 4, 9, 16, 25 \right]
    table(k^2, k = 1..5)

    In the solver, table(k^2, k = 1..5) gives [1, 4, 9, 16, 25].

    Open in the solver
  • table⁡(ij,i=1…3,j=1…3)=(123246369)\displaystyle \operatorname{table}(i j, i = 1 \ldots 3, j = 1 \ldots 3) = \begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9 \end{pmatrix}
    table(i*j, i = 1..3, j = 1..3)

    In the solver, table(i*j, i = 1..3, j = 1..3) gives [[1, 2, 3], [2, 4, 6], [3, 6, 9]].

    Open in the solver
  • take

    The first elements of a list.

  • subsets

    All the sublists of a list that keep its order, as a list.

  • tally

    How often each element occurs: a list of element and count pairs.

  • sort

    A list in increasing order.

  • thread

    Apply a function to corresponding elements of lists.

  • select

    The elements of a list for which a test holds.