Yotsuba Games
Back to Node List

List Enumerate

list_enumerate

Pairs each list element with its index

Draft
Guide available
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
リスト
list
List<Any>
Required
列挙する元のリストです

Output Ports

NameTypeDescription
列挙結果
entries
List<Map>
{ index, item } のマップ一覧です
要素数
count
Int
列挙した要素数です

まず大事なこと

  • このノードは、元の値に 「何番目か」 を付けるノードです
  • 後段の ListMap や ListFilter で index を使いたい時によく使います

まずはこの例

入力リストがこうだとします。

["red", "blue", "green"]

このとき entries はこうなります。

[
  { "index": 0, "item": "red" },
  { "index": 1, "item": "blue" },
  { "index": 2, "item": "green" }
]

count はこうです。

count = 3

後段からどう見えるか

ListMap や ListFilter にこの entries を入れると、各要素は Map なので

  • index
  • item

をそのまま式で使えます。

例:

item + index
index % 2 == 0

どういう時に使うか

  • 候補に番号を付けて debug したい時
  • index を使って条件分岐したい時
  • ListMap / ListFilter から index を読みたい時

注意

  • 各要素の型は保持されるので、item 側には元の値がそのまま入ります
  • Palette 入力は List<Color> として列挙します
Back to Node List
List Enumerate — PixPipeline Node Reference