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(k^2, k = 1..5)In the solver,
Open in the solvertable(k^2, k = 1..5)gives[1, 4, 9, 16, 25].table(i*j, i = 1..3, j = 1..3)In the solver,
Open in the solvertable(i*j, i = 1..3, j = 1..3)gives[[1, 2, 3], [2, 4, 6], [3, 6, 9]].
Related functions
- 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.