SubsetCases
✖
SubsetCases
gives a list of the sublists in list that match the pattern patt in any order.
Details and Options

- In SubsetCases[list,patt], patt can be an expression with head List that includes pattern constructs such as PatternSequence, Repeated (..), Blank (_) and BlankSequence (__).
- The pattern patt can also be a pattern that matches a list but does not itself have head List.
- With the default option setting OverlapsFalse, SubsetCases includes only sublists that do not overlap. With the setting OverlapsTrue, it includes sublists that overlap.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (3)Survey of the scope of standard use cases
Find subsets of variable length:

https://wolfram.com/xid/0enwkmqa6-y35dqp

Combine a variable-length and a fixed-length pattern:

https://wolfram.com/xid/0enwkmqa6-hql8ia

For a variable-length pattern, SubsetCases returns the longest match:

https://wolfram.com/xid/0enwkmqa6-n8yotu

With OverlapsTrue, all possible matches are returned in order of decreasing length:

https://wolfram.com/xid/0enwkmqa6-np94as

SubsetCases tries different branches of Alternatives (|) until one matches:

https://wolfram.com/xid/0enwkmqa6-hhupc3

A different order of the pattern produces a different result:

https://wolfram.com/xid/0enwkmqa6-d5ogt2

Options (1)Common values & functionality for each option
Applications (2)Sample problems that can be solved with this function
Find triangles in a directed graph:

https://wolfram.com/xid/0enwkmqa6-8nue6i

https://wolfram.com/xid/0enwkmqa6-c7tmza

https://wolfram.com/xid/0enwkmqa6-lqnsz9


https://wolfram.com/xid/0enwkmqa6-8ifu36

Find cycles of length four in an undirected graph:

https://wolfram.com/xid/0enwkmqa6-gnzys4

https://wolfram.com/xid/0enwkmqa6-crxgs9


https://wolfram.com/xid/0enwkmqa6-rzyf3n

Properties & Relations (3)Properties of the function, and connections to other functions
The order of elements in each result is determined by the pattern:

https://wolfram.com/xid/0enwkmqa6-0i8udq

https://wolfram.com/xid/0enwkmqa6-1v5oaj

Verify that each result matches the pattern:

https://wolfram.com/xid/0enwkmqa6-of1s2p

Choose a different order of pattern and result:

https://wolfram.com/xid/0enwkmqa6-hmxvt4

https://wolfram.com/xid/0enwkmqa6-ulqz73

Find all subset positions including overlaps:

https://wolfram.com/xid/0enwkmqa6-5c0u39

https://wolfram.com/xid/0enwkmqa6-l5etf9


https://wolfram.com/xid/0enwkmqa6-qr4u5h

The result is equivalent to that of SubsetCases:

https://wolfram.com/xid/0enwkmqa6-bv8p0c


https://wolfram.com/xid/0enwkmqa6-lym1na


https://wolfram.com/xid/0enwkmqa6-rgdb0e

Find the same result using Subsets:

https://wolfram.com/xid/0enwkmqa6-zek9ku


https://wolfram.com/xid/0enwkmqa6-v32gx6

Wolfram Research (2020), SubsetCases, Wolfram Language function, https://reference.wolfram.com/language/ref/SubsetCases.html.
Text
Wolfram Research (2020), SubsetCases, Wolfram Language function, https://reference.wolfram.com/language/ref/SubsetCases.html.
Wolfram Research (2020), SubsetCases, Wolfram Language function, https://reference.wolfram.com/language/ref/SubsetCases.html.
CMS
Wolfram Language. 2020. "SubsetCases." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SubsetCases.html.
Wolfram Language. 2020. "SubsetCases." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SubsetCases.html.
APA
Wolfram Language. (2020). SubsetCases. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SubsetCases.html
Wolfram Language. (2020). SubsetCases. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SubsetCases.html
BibTeX
@misc{reference.wolfram_2025_subsetcases, author="Wolfram Research", title="{SubsetCases}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/SubsetCases.html}", note=[Accessed: 09-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_subsetcases, organization={Wolfram Research}, title={SubsetCases}, year={2020}, url={https://reference.wolfram.com/language/ref/SubsetCases.html}, note=[Accessed: 09-May-2025
]}