List probleme

unhandled

(Benji1235) #1

Hello everyone,

It’s just a very simple question for selecting one of similar items by working with list

How from a list like this 1 1 1 1 2 2 2 1 1 3 3 3 3
I can get one like this 1 x 1 x 2 x x 1 x 3 x x x
Or true false true false true false false true false true false false false
Or 11213

That mean {for i skip i items after i }, but without knowing the index i
The logic is simple but I don’t known know to say it to grasshopper.

Thanks you for your help for this tricky question

Ben


(qythium) #2

Can’t think of a easy way to express recursive logic like this using native GH components (unless resorting to Anemone ) , but here’s a scripted approach:

def shrink(seq, i=0):
  if i < len(seq): 
    del seq[i:i+seq[i]]
    shrink(seq, i+1)

shrink(x)

recursive-list-deletion.gh (5.1 KB)


(Benji1235) #3

Thanks you what I was looking for