Overview
Adds an index to every element in a list. In downstream list_map / list_filter
expressions, the original value is available as item_item and the stored index as
item_index.
Usage tips
- In fact,
list_map/list_filteralready exposeindexfor a raw list, so this node is unnecessary in many cases. Insert it when you want to retain the indexed Map structure itself downstream, such as for debug display or repeated use. - Write index-based conditions such as "even positions only" or "everything but
the first" directly in a
list_filterexpression (for example,index % 2 == 0).
Related nodes
list_map/list_filterโ destinations that use the index (their expressions also provideindex)list_zipโ pair two lists by indexlist_sliceโ extract an index range
Read this first
- This node adds the element's position to each original value.
- It is commonly used when a downstream
List MaporList Filterneedsindex.
Start with this example
Suppose the input list is:
["red", "blue", "green"]
Then entries is:
[
{ "index": 0, "item": "red" },
{ "index": 1, "item": "blue" },
{ "index": 2, "item": "green" }
]
count is:
count = 3
How downstream nodes see it
When these entries go into List Map or List Filter, every element is a Map.
Their expressions can use:
item_item: the original value inside the Mapitem_index: the index stored inside the Map by Enumerateindex: the current position in the outer list being processed by List Map/Filter
Immediately after Enumerate, item_index and index normally have the same number,
but they represent different things.
Examples:
item_item + item_index
index % 2 == 0
When to use it
- When you want to number candidates for debugging
- When you want to branch on an index
- When you need to distinguish the stored
item_indexfrom the outerindex
Notes
- Each element retains its type, so
itemcontains the original value as-is. - A
Paletteinput is enumerated asList<Color>.