List rest of items in designscript

I tried to replicate list rest of items using a codeblock…

Yes I know I can type, “List.RestOfItems” … but I thought this logic would also work:

Can someone explain why index 1 to -1 does not go from index 1 to the last index please? What it does is weird. :astonished:

Hello @Alien, hopefully this helps shed some light :slight_smile:

Alien_DesignScript_GettingDataFromLists.dyn (10.1 KB)

2 Likes

Thanks for that. Also love you called it Alien_DesignScript :laughing:

It is weird then as you can use [-1] and it works fine alone… But you can’t have a range from [1] to [-1].
Any idea why?

:astonished:

So it seems not to recognise [-1] as a index and starts the range at [0]… I think

Negatives work as indices but the syntax you’re using creates a range (1…-1 = [1,0,-1]) so it’s getting those indices moving backwards. If you want the rest of the items in a list then you’ll have to build a range from 1 forward to the last index.

5 Likes

Negatives work as indices but the syntax you’re using creates a range (1…-1 = [1,0,-1]) so it’s getting those indices moving backwards . If you want the rest of the items in a list then you’ll have to build a range from 1 forward to the last index.

Bingo :smiley: Very eloquently put @Nick_Boyts!

Thanks guys.
My confusion stemmed from the fact I thought it worked in Python…
Turns out I was imagining that.
I get a blank list trying that.

image

2 Likes