Find and operate on data pattern sequences using native components?

Are there ways to find particular data patterns easily? I want to find particular patterns in data tree branches to cull items with based on the sequence of data in the branch (e.g. True, True, False or 1600, 1200, 800)?

So for example, if I have a list of curve lengths like below:


I want to remove the duplicates that are either at the start or end of the list.

I’m looking into python to help me with this, because I am suspecting that data patterns can be more easily interacted with through code, but am open for other suggestions. I should be able to get something along the lines of:
“If X is followed by Y, then do Z” or “If X, Y, Z are True, True, False, then do B” without the tree structuring shenanigans.

You can surely use Cull Duplicates and then use the index to find if it is in the beginning or end. Sets could also work but with double value it is more risky, it is better to transform them to int before by dividing them by the tolerance.

Just gave it some thought, with relative differences same values can be converted to indices with ease.

Cull by data pattern_same value.gh (26.9 KB)

No idea yet about true/ false patterns.

if you are fine in looking for exactly two duplicates that are either at the very start or at the very end of each branch, I think something like this might work

but consider that you must have FOR SURE at least 4 items per branch otherwise this will fail very badly because will keep comparing wrong items :joy: I’m indeed a Python noob

if you have let’s say just 3 items, you will end up with a couple of True/False for comparison index 0,1 and another couple of True/False for comparison index 1,2 which is 4 booleans for 3 items

Cull by data pattern_same value_with_stupid_py_code.gh (23.3 KB)