Subtract value at index X from value at index X+1

I have a list of distances (see watch node) and I want to subtract the value at Index X from the value at Index X+1 at list level L1 and return a list of one less value for all my lists, where the index is based on numerical order, see second “List.SortIndexByValue”. Any suggestions?

See example:

EDIT: Just noticed your initial value is always 0, which you’re intending to drop from the list. In that case you could drop the first item of the initial list and run the subtraction from there instead of adding the 0 to the front.


thank you for this @Robert_Younger. I think this should work for me but I’m not sure what you are doing in the code block to get the 1 at the front. I’m assuming this is somehow indicating which index number I am telling the list to drop? What do I type into the code block for that?

Edit: I was able to make it work when I set the list level in the List.DropItems but I would still like to know what you’re doing.

List.DropItems will remove the amount of items from the list that you tell it. If it’s a positive number, it’ll take them off the start of the list, if it’s negative like in the above example, it’ll take them off the end.

Or do you just mean the “1” row/line count in the code blocks? That’s just a thing in newer versions of Dynamo.

1 Like