Welcome to the next stage of our journey into Grasshopper's data structures. In the previous lesson, we learned how to actively reshape a single data stream using the fundamental operations of Flatten, Graft, and Simplify. You now have the tools to control the hierarchy of a data tree. Today, we address the logical next question: what happens when a component receives multiple data streams, especially when they don't have the same number of items?
This lesson is dedicated to mastering data matching. We will explore the three principal algorithms Grasshopper uses to pair items from different input lists: Shortest List, Longest List, and Cross Reference. Understanding and controlling these rules is paramount, as they determine how geometric elements relate to one another, directly shaping the output of your parametric models. By the end of our session, you'll be able to intentionally choose the correct matching strategy to achieve your specific design goal.
The Core Problem: Mismatched Lists
Imagine you have a component that draws lines between points, like the Line component. It expects a list of start points (Input A) and a list of end points (Input B).
- If List A has 10 points and List B has 10 points, the logic is simple: point A[0] connects to B[0], A[1] to B[1], and so on. This is a one-to-one correspondence.
- But what if List A has 10 points and List B has only 5? How should the
Linecomponent connect the remaining 5 points from List A? Should it stop? Should it reuse points from List B?
Grasshopper provides explicit rules to resolve this ambiguity, and the default behavior is called the "Longest List" algorithm.
1. Longest List: The Default Behavior
By default, Grasshopper will always continue an operation until the longest input list is exhausted. When a shorter list runs out of items, Grasshopper simply reuses the last item from that shorter list for all remaining operations.
Let's take our example: 10 start points (List A) and 5 end points (List B).
- Lines 0 through 4 are drawn as expected: A[0]→B[0], A[1]→B[1], ..., A[4]→B[4].
- When it comes to start point A[5], List B is out of items. Grasshopper reuses the last item, B[4]. So, A[5]→B[4].
- This continues for the rest of List A: A[6]→B[4], A[7]→B[4], ..., A[9]→B[4].
The result is a "fan-out" from the last item of the shorter list. The following video demonstrates this default behavior clearly.
Grasshopper 101: Data Lists | #06 Longest List | Data List Matching
This video from the Learn Visual Programming channel first shows how matching works with lists of equal length, then demonstrates Grasshopper's default "Longest List" behavior when the lists are mismatched.
First, watch the introductory segment on matching indices to see the simple one-to-one case. Then, pay close attention to the section from setting up the problem, where the presenter creates two lists of points with different lengths and connects them. Observe how the lines converge on the last point of the shorter list.
While this is the default behavior, you can also enforce it explicitly using the Longest List component or by right-clicking an input and selecting it from the menu.

The Rhino developer documentation provides a concise textual summary of this behavior.
Chapter 2: Introduction to Data Structures - Rhino
This guide explains the data matching options available in Grasshopper.
Please read the section titled 2.4 List matching. Focus on the text and images explaining the default behavior and the "Long" matching option.
2. Shortest List: Truncating the Operation
The "Shortest List" algorithm is the most conservative approach. The operation runs only as long as all input lists can provide a new item. As soon as the shortest list runs out, the entire process stops.
In our example with 10 start points and 5 end points, a Shortest List match would produce only 5 lines (A[0]→B[0] through A[4]→B[4]). The remaining points in List A (A[5] through A[9]) are simply ignored for this operation. This method ensures you never work with repeated or "recycled" data.
Let's see this in action with the companion video to the one we just watched.
Grasshopper 101: Data Lists | #07 Shortest List | Data List Matching
This video continues with the same setup as before, but introduces the Shortest List component to alter the matching behavior.
Watch the segment from this timestamp. Notice how adding the Shortest List component immediately changes the outcome, "trimming" the operation to match the length of the shorter list of points.
This method is useful when you need to ensure a strict pairing of data and want to discard any excess items. The Mode Lab Grasshopper Primer offers an excellent, detailed explanation with clear diagrams.
[PDF] Mode Lab Grasshopper Primer Third Edition - aae 280 fall 2014
This section of the primer provides a thorough visual and textual explanation of all three data matching algorithms.
Find the section titled F.3.2 Data Stream Matching. Read the paragraphs and examine the diagrams for "Shortest List" and "Longest List". Compare the visual representations of how the connections are made.
3. Cross Reference: The Cartesian Product
The "Cross Reference" algorithm is fundamentally different. Instead of pairing items one-to-one, it creates all possible combinations between the items of the input lists.
Given your background in mathematics, you can think of this as generating the Cartesian product of the input sets. If you have List A with items and List B with items, a Cross Reference operation will produce a data structure containing results, representing every pair (A[i], B[j]).
When would you use this? A classic example is generating a grid of points. If you have a list of X-coordinates and a list of Y-coordinates, a Cross Reference match on the Construct Point component will generate a point for every possible (X, Y) combination, forming a complete 2D grid.
The Rhino developer guide provides a perfect tutorial for this exact use case.
Chapter 2: Introduction to Data Structures - Rhino
Let's return to the Rhino developer guide to see a practical application of Cross Reference.
First, read the paragraph defining Cross Reference. Then, work through the short tutorial that follows, Tutorial 2_4_1. This example shows how to use Cross Reference on three lists of coordinates (X, Y, and Z) to generate a 3D grid of 216 points—a quintessential parametric task.
This method is incredibly powerful for creating combinatorial arrays and patterns, but it must be used with caution. The number of outputs can grow very quickly (e.g., crossing three lists of 100 items each results in 1,000,000 operations), which can slow down or freeze your definition.
Visual Summary
The image below provides a clear, abstract summary of the three matching strategies we've discussed.

Conclusion
You have now learned how Grasshopper resolves operations with multiple, unevenly sized inputs. Mastering these three data matching algorithms gives you precise control over the relationships between data streams, which is a cornerstone of effective parametric modeling.
Key Takeaways:
- Longest List (Default): The operation continues until the longest list is exhausted. The last item of any shorter list is repeated as needed. This is useful for propagating a single condition or element across many others.
- Shortest List: The operation stops when the shortest list runs out of items. This "truncates" the output, ensuring a strict one-to-one pairing and discarding excess data.
- Cross Reference: This creates all possible combinations of inputs, equivalent to a Cartesian product. It is ideal for generating grids, arrays, and combinatorial patterns but can be computationally expensive.
- You can control the matching strategy by using the dedicated components (
Shortest List,Longest List,Cross Reference) or by right-clicking on a component's input parameter.
In our next lesson, we will continue our exploration of data trees by learning how to retrieve specific data. Now that you can generate and structure data with precision, we will focus on selecting specific items and branches from a data tree using selection and filtering components.