Why doesn't "-1" work as an input for "Split List" index?

Apple Bazooka Pancreas.gh (5.9 KB)


It would be nifty to directly have the last item (like after sorting to find the longest curve for example) and also all the others in a separate list.

use the list item component.

1 Like

Or use Python, there list slicing works. The Split List doesn’t do slicing in that sense.

1 Like

Hi Tom, thanks, I had heard about that “List Item” component :wink:

Here’s the issue :

Hi Nathan,

Thanks, I’ll keep that in the back of my mind for when I’ll have time to do Pyton scripting.
Let’s say my question is more like a wish for “Split list” to accept the negative indexes.

Here, to help remedy the required effort of writing code (2 lines of real action):

Split List using Python Slices.ghuser (2.4 KB)

1 Like

You can also use the list length component and an expression of x-1 ( or a subtraction component with 1) to split the list at the last item:

…which is what I did

@DavidRutten ; I am mostly wondering why “-1” doesn’t work with Split.
If there’s no valid reason, then I guess it should be implemented, for consistency.

I would agree that it should ‘wrap’ if a negative index is supplied.