MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Applying List of Functions To List Of Arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30203] Re: Applying List of Functions To List Of Arguments
  • From: Roland Franzius <Roland.franzius at uos.de>
  • Date: Thu, 2 Aug 2001 03:15:58 -0400 (EDT)
  • References: <9k88rv$55o$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

among the many possible ways I would try these solutions:

1. Use a permanent definition of a listable function , say Eval
F={f,g,h};X{x,y,z};
SetAttributes[Eval,Listable];
Eval[f_,x_]:=f[x];

Eval[F,X]
    {f[x],g[y],h[z]}
This definition would always go down to the lowest level of lists with
equal tree structure  pairing functions and their arguments

2. Do it on the fly using Inner[  ] with an applicating function on pairs
and List instead of Plus

Inner[ ( #1[#2]& ) , F, X, List]

{f[x],g[y],h[z]}

3. or by pairing and pattern replacement

Transpose[{F,X}]/.{a_,b_}:>a[b]
Pattern replacement may be inconvenient if 2-sublists exist in arguments.

4. or by pairing and mapping an Apply of the
Evaluation-of-function-at-argument onto the pairs {f,x}

(#1[#2]&)@@@Transpose[{F,X}]


Regards
Roland Franzius

Ronnen Levinson wrote:

> Hi.
>
> What function or operator will let me apply a list of functions to a
> list of arguments? That is, I'd like to apply {f1,f2,f3} to {a,b,c} to
> get {f1[a],f2[b],f3[c]}.
>
> Yours truly,
>
> Ronnen.



  • Prev by Date: Re: How to clear OverBar[p]
  • Next by Date: Re:Applying List of Functions To List Of Arguments
  • Previous by thread: Re: Applying List of Functions To List Of Arguments
  • Next by thread: Re:Applying List of Functions To List Of Arguments