# Selective list deletions

I have a list:

lis = {{a,b,c},{d},{e,f},{g},{h,i,j}}


I would like to remove each element that consists of only one subelement from the list to get:

res = {{a,b,c},{e,f},{h,i,j}}


This seems to be for SequenceReplace, but I'm having trouble with structuring the command.

Cases[lis, Except[{_}]] should be good.

OR

Select[lis, Length[#] > 1 &]

Pick[lis, Length[#] > 1 & /@ lis]

DeleteCases[lis, {_}]

lis /. {_} -> Nothing


EDIT a few more

Select[lis, Rest[#] != {} &]

Select[lis, Most[#] != {} &]

Select[lis, Last@TakeDrop[#, 1] != {} &]

• Cases, DeleteCases, and Select can all be used here. But as a purely aesthetic point, I would prefer to use either Cases or Select so that I can know with certainty the structure of the elements that I have retained in the next step. With DeleteCases, I would need to use the structure up to that point, and the pattern I have chosen to delete, in order to come to a conclusion about the structure of the result. Commented Oct 7, 2021 at 17:17
Cases[{_, __}] @ lis

{{a, b, c}, {e, f}, {h, i, j}}

list = {{a, b, c}, {d}, {e, f}, {g}, {h, i, j}};


Using SequenceSplit (new in 11.3)

Catenate @ SequenceSplit[list, {{_}}]


{{a, b, c}, {e, f}, {h, i, j}}

list = {{a, b, c}, {d}, {e, f}, {g}, {h, i, j}};


Using GroupBy:

GroupBy[list, Length@# > 1 &][True]

(*{{a, b, c}, {e, f}, {h, i, j}}*)


Or using Replace at level 1:

Replace[list, s : {_} :> Nothing, {1}]

(*{{a, b, c}, {e, f}, {h, i, j}}*)

• I always forget these nice GroupBy solutions :)
– eldo
Commented Mar 13 at 0:21
• Thanks, @eldo ;) Commented Mar 13 at 0:22