mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
49 lines
1.6 KiB
Markdown
49 lines
1.6 KiB
Markdown
# Function range
|
|
|
|
Create an array from a range.
|
|
By default, the range end is excluded. This can be customized by providing
|
|
an extra parameter `includeEnd`.
|
|
|
|
The method accepts the following arguments
|
|
range(str [, includeEnd]) Create a range from a string,
|
|
where the string contains the
|
|
start, optional step, and end,
|
|
separated by a colon.
|
|
range(start, end [, includeEnd]) Create a range with start and
|
|
end and a step size of 1.
|
|
range(start, end, step [, includeEnd]) Create a range with start, step,
|
|
and end.
|
|
|
|
Where:
|
|
{String} str
|
|
{Number | BigNumber} start Start of the range
|
|
{Number | BigNumber} end End of the range, excluded by default,
|
|
included when parameter includeEnd=true
|
|
{Number | BigNumber} step=1 Step size.
|
|
{boolean} includeEnd=false Option to specify whether to include
|
|
the end or not.
|
|
|
|
Example usage:
|
|
math.range(2, 6); // [2,3,4,5]
|
|
math.range(2, -3, -1); // [2,1,0,-1,-2]
|
|
math.range('2:1:6'); // [2,3,4,5]
|
|
math.range(2, 6, true); // [2,3,4,5,6]
|
|
|
|
|
|
### Parameters
|
|
|
|
Parameter | Type | Description
|
|
--------- | ---- | -----------
|
|
`args` | ...* |
|
|
|
|
### Returns
|
|
|
|
Type | Description
|
|
---- | -----------
|
|
Array | Matrix | range
|
|
|
|
|
|
|
|
|
|
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|