SubsetMap
SubsetMap[f,{e1,e2,…},{i,j,…}]
yields an expression in which the elements ei, ej, … in the list {e1,e2,…} are replaced with the corresponding elements of the list obtained by evaluating f[{ei,ej,…}].
SubsetMap[f,expr,{pos1,pos2,…}]
replaces elements of expr at positions pos1, pos2, ….
Details
- In SubsetMap[f,list,{i1,…,in}], the function f takes a length-n sublist of list and is expected to return another list of length n, whose elements will replace those of the original sublist.
Examples
open allclose allBasic Examples (5)
Scope (4)
Reverse the elements at even positions in a list:
Use equivalent notations for the position argument:
Use SubsetMap as an operator form to show that these words are "even-letter palindromes":
Shift periodically the central elements of a list of colors:
Applications (1)
Properties & Relations (4)
Possible Issues (2)
If the list of positions is not canonically sorted, the result will inherit that order:
In SubsetMap[f,expr,{i,j,…}], the list {i,j,…} represents a list of positions, equivalent to {{i},{j},…}:
Other functions using position specifications, like Extract, interpret a list of integers as a single position:
Text
Wolfram Research (2019), SubsetMap, Wolfram Language function, https://reference.wolfram.com/language/ref/SubsetMap.html.
CMS
Wolfram Language. 2019. "SubsetMap." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SubsetMap.html.
APA
Wolfram Language. (2019). SubsetMap. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SubsetMap.html