跳转到内容

This page is also in English.

Read it in English

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

Léela en español

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

日本語で読む

map_thread 函数

对多个列表中对应的元素应用一个函数。

怎么写

map_thread(f, lists)

f
要应用的函数。接受一个函数。
lists
由等长列表构成的列表。接受一个列表。

示例

  • map_thread⁡(plus⁡,(1234))=[4,6]\displaystyle \operatorname{map\_thread}\left(\operatorname{plus}, \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\right) = \left[ 4, 6 \right]
    map_thread(plus, [[1, 2], [3, 4]])

    在求解器中,map_thread(plus, [[1, 2], [3, 4]]) 的结果是 [4, 6]。

    在求解器中打开
  • map

    对列表中的每个元素应用一个函数。

  • thread

    把函数应用到列表的对应元素上。

  • most

    去掉最后一个元素的列表。

  • nest

    对一个值反复应用函数。

  • list

    由参数构成的列表。

  • nest_list

    nest 的各个步骤:每次应用后的值,从第一次开始。