ComapApply[{f1,f2,…},expr]
ComapApply[fs]
represents an operator form of ComapApply that can be applied to an expression.
ComapApply
ComapApply[{f1,f2,…},expr]
ComapApply[fs]
represents an operator form of ComapApply that can be applied to an expression.
Details and Options
- ComapApply is typically used to apply each of a list of functions to the same sequence of arguments. »
- With the option setting HeadsTrue, ComapApply includes heads of expressions and their parts. »
- ComapApply always effectively constructs a complete new expression and then evaluates it. »
- The head of fs in ComapApply[fs,expr] need not be List.
- If fs is an Association object, ComapApply[fs,expr] replaces the head of expr with the values in the association. »
- ComapApply[fs][expr] is equivalent to ComapApply[fs,expr].
- Parallelize[ComapApply[fs,expr]] computes ComapApply[fs,expr] in parallel on all subkernels. »
Examples
open all close allBasic Examples (3)
Replace the head of {1,2} with each element of a list:
ComapApply[{f, g, h}, {1, 2}]Use the operator form of ComapApply:
ComapApply[{f, g, h}][{1, 2, 3}]Replace the head of an expression with the values in an association:
ComapApply[<|"a" -> f, "b" -> g, "c" -> h|>, {x, y}]Scope (3)
ComapApply[{1 + f[#, #2]&, 2 + g[#, #2]&, 3 + h[#, #2]&}, {1, 2}]ComapApply[{{x, y} |-> x + y, {x, y} |-> x y}, {3, 4}]ComapApply can be used on expressions with any head:
ComapApply[f[a, b], g[x, y]]Replace the head of an expression with the values of an Association:
ComapApply[<|"a" -> f, "b" -> g|>, {1, 2}]Options (1)
Properties & Relations (8)
ComapApply successively replaces the head of an expression with the parts of another expression:
ComapApply[{f, g, h}, head[x, y]]MapApply replaces the head of each part of an expression with another expression:
MapApply[f, {head[x, y], head[a, b], immaterial[1, 2]}]Through[p[f,g,…][x,y,…]] is equivalent to ComapApply[p[f,g,…],{x,y,…}]:
Through[{f, g, h}[x, y, z]]ComapApply[{f, g, h}, {x, y, z}]Compare this to the operator form of ComapApply:
ComapApply[{f, g, h}][{x, y, z}]ComapApply[p[f,g,…],{x,y,…}] can be used even when p[f,g,…][x,y,…] has a value:
ComapApply[<|"a" -> f, "b" -> g|>, {x, y, z}]When p[f,g,…][x,y,…] has a value, Through cannot be used:
<|"a" -> f, "b" -> g|>[x, y, z]Through[<|"a" -> f, "b" -> g|>[x, y, z]]ComapApply[{f1,f2,…},expr] is equivalent to Map[f|->Apply[f,expr],{f1,f2,…}] when the fi have no attributes:
ComapApply[{f, g, h}, {x, y}]Map[e |-> Apply[e, {x, y}], {f, g, h}]ComapApply can replace the head of an expression with parts inside held expressions without allowing evaluation to proceed:
ComapApply[Hold[Plus, Times], {2, 3, 4}]Use ReleaseHold to allow evaluation to proceed:
ReleaseHold[{%}]If only some arguments are held, only those arguments will not evaluate further:
SetAttributes[h, HoldRest]ComapApply[h[Plus, Times], {2, 3, 4}]Use Unevaluated to replace the head of an expression with different expressions without evaluating it first:
ComapApply[{f, g}, Unevaluated[a + b + a]]The expression is evaluated first by default:
ComapApply[{f, g}, a + b + a]Use Unevaluated to replace the head of an expression with the parts of an expression without evaluating it first:
ComapApply[Unevaluated[f g f], {1, 2}]The expression is evaluated first by default:
ComapApply[f g f, {1, 2}]ComapApply can be parallelized automatically:
Parallelize[ComapApply[{f, g, h}, {1, 2}]]Tech Notes
History
Text
Wolfram Research (2024), ComapApply, Wolfram Language function, https://reference.wolfram.com/language/ref/ComapApply.html.
CMS
Wolfram Language. 2024. "ComapApply." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ComapApply.html.
APA
Wolfram Language. (2024). ComapApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ComapApply.html
BibTeX
@misc{reference.wolfram_2026_comapapply, author="Wolfram Research", title="{ComapApply}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/ComapApply.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_comapapply, organization={Wolfram Research}, title={ComapApply}, year={2024}, url={https://reference.wolfram.com/language/ref/ComapApply.html}, note=[Accessed: 13-June-2026]}