Quantcast
Channel: Applying several functions to the same argument - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 7

Answer by user1066 for Applying several functions to the same argument

$
0
0

Although not more concise, it might be worth noting (as pointed out by Wagner, p196) that a pure function may be made listable using Function[] syntax (but not, as far as I am aware, with either #-& or d |-> syntax).

{f1, f2} // Function[x, x[Exponent[#, Variables[expr]]] &, Listable](* {f1[Exponent[#1, Variables[expr]]] &, f2[Exponent[#1, Variables[expr]]] &} *)

The following will also work:

myfn = Function[x, (x[Exponent[#, Variables[expr]]] &), Listable];myfn[{f1, f2}](* {f1[Exponent[#1, Variables[expr]]] &, f2[Exponent[#1, Variables[expr]]] &} *)

But (as again pointed out by Wagner), the following won't, as the listable attribute is 'stripped off' when fn is replaced by its ownvalue during evaluation:

fn = Function[x, (x[Exponent[#, Variables[expr]]] &)];SetAttributes[fn, Listable]fn[{f1, f2}](* {f1, f2}[Exponent[#1, Variables[expr]]] & *)

Viewing all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>