Grouping identical numbers


How can it be achieved without plugins

Grouping adjacent numbers_EW.gh (7.8 KB)

no plugins used only python code


Grouping adjacent numbers_rp00.gh (5.3 KB)

Adjacent?

Wouldn’t ‘identical‘ be a better word?

Yes, I didn’t express myself very well

Can native components of Gh be used

What I want is consecutive identical

For example, the input list,[1,1,2,2,2,3,3,1], [1] will be grouped into {[1, 1], [2,2,2], [3], [1]}, and output with tree structure.

I changed the topic title for you.

@Eef_Weenink solution uses native components…

Uploading: 2.png…
Improve the functions

getting closer


Grouping adjacent numbers_EW.gh (9.8 KB)

sir ,not what l want
‘Expression’ Perhaps screening can be achieved

Explanation:

  • I have to divide a list in groups. So every time the next item is NOT the same, we want the number of that. This is done by shift list -1 (compare to item we have seen before).
  • Idential then True. If not False (because you use text + numbers I uses Match Text)
  • Using Dispatch we have a list of every first item of a group.
  • Using List Index we have also the index number.
  • We want to select these groups. With something like:
    From First item to the one before next First item. So I use the Shift List again (Wrap = False, ) because we want only to end of list.
  • List Length to find last of list
  • Series to make the numbers in every group.
  • List item to finish it off.


Grouping adjacent numbers_EW.gh (7.3 KB)

@Eef_Weenink Awesome

Very good