Let's say I have a list of pure functions that are nice algebraic expressions: say
l = {(#1 - 1)&, (#1^2 + #1)&, (#1^3 - 1)&}
What's an easy way to get a pure function that will give the product of these expressions? For example, in the above I'd like to get a function f with
f = (#1 - 1)(#1^2 + #1)(#1^3 - 1)&
I've tried (Times @@ Identity @@@ l)&
, but this just gives (#1 - 1)(#1^2 + #1)(#1^3 - 1)
. Essentially, it seems my difficulty is converting a List
of Function
expressions to a Function[Times[...]]
expression, and I can't see how to "strip off" the functions without messing up the referencing of the Slot[1]
expressions inside.
Thanks for any help.
Function[x, Times @@ Through[l[x]]]
? But thanks for pointing that out, @Jonathan Shock $\endgroup$Through
is clever. Thanks for your help! $\endgroup$