Re: innerApply[{f, g}, {{a, b}, {c, d}}] = {f[a, b], g[c, d]} ?
- To: mathgroup at smc.vnet.net
- Subject: [mg109743] Re: innerApply[{f, g}, {{a, b}, {c, d}}] = {f[a, b], g[c, d]} ?
- From: Ray Koopman <koopman at sfu.ca>
- Date: Fri, 14 May 2010 05:36:41 -0400 (EDT)
- References: <hsgnjt$d6o$1@smc.vnet.net>
On May 13, 4:25 am, Fred Klingener <gigabitbuc... at BrockEng.com> wrote: > This seems to work fine, but there must be a less clumsy way to do it: > > Clear[innerApply, functionList, argumentList, f, g, a, b, c, d] > > innerApply[functionList_, argumentList_] := > Table[functionList[[j]] @@ argumentList[[j]], {j, 1, > Length[functionList]}] > > In[770]:= innerApply[{f, g}, {{a, b}, {c, d}}] > Out[770]= {f[a, b], g[c, d]} > > TIA, > Fred Klingener This will always work: In[1]:= MapThread[Apply,{{f,g},{{a,b},{c,d}}}] Out[1]= {f[a,b],g[c,d]} This will work only if the sublists in the second list have different lengths: In[2]:= Inner[Apply,{f,g},{{a,b},{c,d,e}},List] Out[2]= {f[a,b],g[c,d,e]}