SubsetPosition[list,sublist]
gives a list of positions at which sublist appears in list in any order.
SubsetPosition[list,patt]
gives all positions at which sublists matching patt in any order appear in list.
SubsetPosition[list,patt,n]
includes only the first n positions.
SubsetPosition
SubsetPosition[list,sublist]
gives a list of positions at which sublist appears in list in any order.
SubsetPosition[list,patt]
gives all positions at which sublists matching patt in any order appear in list.
SubsetPosition[list,patt,n]
includes only the first n positions.
Details and Options
- In SubsetPosition[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 OverlapsTrue, SubsetPosition includes sublists that overlap. With the setting OverlapsFalse, such sublists are excluded.
Examples
open all close allBasic Examples (1)
Scope (3)
Find the positions of a sublist:
SubsetPosition[{1, 2, 3, 4, 1, 3}, {1, 3}]SubsetPosition[{1, 2, 3, 4, 1, 3}, {1, 3, 4}]Find the positions of blank patterns:
SubsetPosition[{1, 2, 3}, {_}]SubsetPosition[{1, 2, 3, 4}, {_, _}]SubsetPosition[{1, 2, 3}, {__}]Find the positions of a combination of a blank and explicit value:
SubsetPosition[{1, 2, 3, 4}, {1, _}]The order of positions is determined by the specified pattern:
SubsetPosition[{1, 2, 3, 4}, {_, 1}]Options (1)
Properties & Relations (2)
SubsetPosition effectively finds positions of each component of the pattern and combines them:
SubsetPosition[list = {1, 2, 3, 4, 1, 3}, {1, 3}]Find the positions of the sublist members:
p1 = Position[list, 1]//Flattenp3 = Position[list, 3]//FlattenFlatten[Outer[List, p1, p3], 1]The order within each result of SubsetPosition is determined by the pattern:
l = {1, 2, 3, 4, 5, "a", "b"};
patt = {_Integer, _String, _Integer};SubsetPosition[l, patt, Overlaps -> False]Extract subsets corresponding to each result:
l[[#]]& /@ %Verify that each subset matches the pattern:
AllTrue[%, MatchQ[patt]]Related Guides
History
Text
Wolfram Research (2020), SubsetPosition, Wolfram Language function, https://reference.wolfram.com/language/ref/SubsetPosition.html.
CMS
Wolfram Language. 2020. "SubsetPosition." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SubsetPosition.html.
APA
Wolfram Language. (2020). SubsetPosition. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SubsetPosition.html
BibTeX
@misc{reference.wolfram_2026_subsetposition, author="Wolfram Research", title="{SubsetPosition}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/SubsetPosition.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_subsetposition, organization={Wolfram Research}, title={SubsetPosition}, year={2020}, url={https://reference.wolfram.com/language/ref/SubsetPosition.html}, note=[Accessed: 13-June-2026]}