Oops...

This website is made for modern browsers. You are seeing this, because your browser is missing a feature or two. Please install the latest update or switch to a modern browser. See you soon.

Merge lists

#lists

The methods presented below can be used to merge and combine lists or to replace list items. The goal is to work with several lists and their matching. See Filter lists to learn about extracting specific items from a list.

Merge data streams (Merge)

The component Mergecan be used to merge various lists (and data trees). If an undesired data treeis created, the option Flatten can be used on the inputs to obtain a single list as output. It is possible to add and remove inputs via the ZUI.

Choose items by selecting each index individually (Pick’n’Choose)

The component Pick'n'Choosewill merge items from various list according to a pattern of selectors at input P. If the pattern is depleted, it will not be repeated; the emitted list will have the same length as the pattern. More input s can be added via ZUI.

Choose items with a given pattern (Weave)

The component Weavewill also merge items from various lists according to a given pattern at input P. However, unlike Pick’n’Choose, the pattern is repeated if the input lists are longer than the pattern. Again, the ZUI can be used to add more inputs.

Once all items in a list are used up, data items are still added to the output if there are items left in other lists. This way, the desired pattern may be violated towards the end. To avoid this, null-items can be added by right-clicking the component and selecting Insert Nulls.

Fill the index of null-items with other items (Combine Data)

If a list contains any null-items, the component Combine Datacan be used to fill their indices with items from another list that has the same index. The ZUI can be used to add additional inputs.

Replace null-items with other items (Replace Nulls)

The component Replace Nullsis similar to Combine Data, but it’s not using replacement items with the same index. Instead, the replacement items are pulled consecutively from the spare list.

Replace items in a list (Replace)

The component Replace Itemscan be used to replace items in a given list L with items provided at input I. Input i states which indices will be replaced with new items. If there are no items given at input I, null-items will be used as replacement.

Add elements to a list (Insert Items)

The component Insert Itemscan be used to add additional items to a list L. Input I is providing the items and input i sets their corresponding new index.

Interconnect items (Cross Reference)

The component Cross Referencecan be used to form an interconnection between the items of the input lists (more can be added via ZUI). By default, all items from one list are connected with all others from another list. The component can be right-clicked and another combination patterns may be chosen.

Equalize the length of lists (Longest List, Shortest List)

The component Longest Listcan be used to make a shorter list match its length. By default, this is done by repeating the last item the necessary number of times. This is also the default behavior for most components that take 2 or more corresponding data inputs. Longest List can be right-clicked to choose different options of how to extend the shorter list.

If the longer list should be shortened to match the shorter list, then Shortest Listcan be used. Also, different options can be selected in the context menu. Both components can be extended via ZUI to add more inputs.

Merge lists by considering their values

The components introduced so far operate on list items independent of their values. In the ribbon tab Sets there is a subgroup Sets which contains several components that operate with lists but regard the items' values. This is only possible for Primitive Data Types, which are texts, numbers and data that can be cast in string format (like points and vectors).

The component Set Unioncan be used to merge two or more lists into one by avoiding duplicate values. Thus, we receive unique values.

Other components work similarly, like Set Difference (S)(emits values that occur only once in all input lists) or Set Intersection(emits values that occur in each of the input lists).

Combine lists into one item

For Primitive Data Types (see above) it’s possible to combine their values into a single string with the component Concatenate. A separator can be set in the context menu (here space) and additional input grips can be added via ZUI.

The component Text Joinis similar and will combine all values in a list T with a given separator J (here space).

These methods, and other components in Sets > Text, can be quite helpful to convert data to a text format that can then be exported to other programs.

This page is open source. Edit it on GitHub or see how you can contribute.

Up next