函数索引 #

创建一个索引。一个 Index 可以存储具有多个维度的 start、step 和 end 的范围。Matrix.get、Matrix.set 和 math.subset 接受 Index 作为输入。

Syntax #

math.index(range1, range2, ...)

Where #

Parameters #

Parameter Type Description
范围 零个或多个范围或数字。

Returns #

Type Description
Index 返回创建的索引

Throws #

Type | Description —- | ———–

Examples #

const b = [1, 2, 3, 4, 5]
math.subset(b, math.index([1, 2, 3]))                         // returns [2, 3, 4]
math.subset(b, math.index([false, true, true, true, false]))  // returns [2, 3, 4]

const a = math.matrix([[1, 2], [3, 4]])
a.subset(math.index(0, 1))             // returns 2
a.subset(math.index(0, [false, true])) // returns 2

另请参阅 #

bignumber, boolean, complex, matrix, number, string, unit

Fork me on GitHub