I do not know if this is question has already been asked but I did see some posts on deleting duplicate elements but I am unable to understand completely. So forgive me if this turns out to be duplicate.
I have a list of the form {{a,b,a,b},{b,a,b,a},{a,a,b,b},{b,b,a,a},{a,b,b,a},{b,a,a,b}}
. I need to eliminate sublist which have same consecutive elements.
Example I should eliminate {a,a,b,b}
, {b,b,a,a}
, {a,b,b,a}
and {b,a,a,b}
and thus end up with only alternating a
s and b
s.
Any suggestions will be appreciated. Thanks in advance.
DeleteCases[lst, {___, x_, x_, ___}]
where lst is your target list. $\endgroup$___
isBlankNullSequence
so this will work for aList
of any length. $\endgroup$