FlattenAt[list,n]
flattens out a sublist that appears as the n th element of list. If n is negative, the position is counted from the end.
FlattenAt[expr,{i,j,…}]
flattens out the part of expr at position {i,j,…}.
FlattenAt[expr,{{i1,j1,…},{i2,j2,…},…}]
flattens out parts of expr at several positions.
FlattenAt
FlattenAt[list,n]
flattens out a sublist that appears as the n th element of list. If n is negative, the position is counted from the end.
FlattenAt[expr,{i,j,…}]
flattens out the part of expr at position {i,j,…}.
FlattenAt[expr,{{i1,j1,…},{i2,j2,…},…}]
flattens out parts of expr at several positions.
Examples
open all close allBasic Examples (2)
Scope (3)
FlattenAt can splice the arguments of any expression, not just lists:
FlattenAt[f[g[1, 2], g[3, 4], g[5]], {2}]mat = Array[a, {2, 2}]Flatten the first element (row) of the matrix:
FlattenAt[mat, 1]FlattenAt[mat, {1}]Flatten at position 1,2 (the element in the first row, second column):
FlattenAt[mat, {1, 2}]Flatten at positions 1 and 2 (the rows) of the matrix:
FlattenAt[mat, {{1}, {2}}]Create an operator form of FlattenAt:
op = FlattenAt[1]Apply the operator to different expressions:
op[{{1, 2}, {3, 4}}]op[{f[1, 2], g[3, 4]}]Properties & Relations (2)
For lists, FlattenAt[list,pos] is equivalent to MapAt[Splice,list,pos]:
FlattenAt[{a, {b, {c}}, d, {e}}, {{2, 2}, {4}}]MapAt[Splice, {a, {b, {c}}, d, {e}}, {{2, 2}, {4}}]For a general expression, FlattenAt[expr,pos] is equivalent to MapAt[Delete[0],expr,pos]:
FlattenAt[f[a, g[b, c], d, {e}], {{2}, {4}}]MapAt[Delete[0], f[a, g[b, c], d, {e}], {{2}, {4}}]See Also
DeleteCases Flatten Splice Sequence SlotSequence Delete Insert MapAt ReplacePart ArrayFlatten
Function Repository: BeheadAt
Tech Notes
Related Guides
History
Introduced in 1991 (2.0)
Text
Wolfram Research (1991), FlattenAt, Wolfram Language function, https://reference.wolfram.com/language/ref/FlattenAt.html.
CMS
Wolfram Language. 1991. "FlattenAt." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FlattenAt.html.
APA
Wolfram Language. (1991). FlattenAt. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FlattenAt.html
BibTeX
@misc{reference.wolfram_2026_flattenat, author="Wolfram Research", title="{FlattenAt}", year="1991", howpublished="\url{https://reference.wolfram.com/language/ref/FlattenAt.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_flattenat, organization={Wolfram Research}, title={FlattenAt}, year={1991}, url={https://reference.wolfram.com/language/ref/FlattenAt.html}, note=[Accessed: 13-June-2026]}