MathGroup Archive 2002

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

Search the Archive

RE: Thread? Through? Operate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32407] RE: [mg32388] Thread? Through? Operate?
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 19 Jan 2002 01:16:45 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Johannes,

funcs = {f1, f2, f3, f4};
args = {x1, x2, x3, x4};

The following forms are only marginally, if at all, better than you have.

MapThread[#1[#2] &, {funcs, args}]
{f1[x1], f2[x2], f3[x3], f4[x4]}

Inner[#1[#2] &, funcs, args, List]
{f1[x1], f2[x2], f3[x3], f4[x4]}

But, if you have to do a lot of it you could define your own function to
shorten it.

tt[funcs_, args_] := Inner[#1[#2] &, funcs, args, List]

funcs~tt~args
{f1[x1], f2[x2], f3[x3], f4[x4]}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> From: Johannes Ludsteck
To: mathgroup at smc.vnet.net
> [mailto:johannes.ludsteck at wiwi.uni-regensburg.de]
>
> Dear MathGroup members,
> I have a list of n unnamed functions
>
> f = {expr1 &, expr2 &,... ,exprn &}
> (each function has exactly one arguement.
> and a list of n arguments.
>
> arg = {arg1, arg2,... ,argn}
>
> I simply want to apply each function expri &
> to the respective argument argi in order
> to obtain the list of function values fi.
> Is there no more elegant way than the following one?
>
> Map[#[[1]][#[[2]]]&, Transpose[{f,arg}]
>
> Thanks,
> 	Johannes
>
> <><><><><><><><><><><><><><><><><><>
> Johannes Ludsteck
> Institut fuer Volkswirtschaftslehre
> Lehrstuhl Prof. Dr. Moeller
> Universitaet Regensburg
> Universitaetsstrasse 31
> 93053 Regensburg
> Tel +49/0941/943-2741
>



  • Prev by Date: Re: Thread? Through? Operate?
  • Next by Date: Re: Thread? Through? Operate?
  • Previous by thread: Re: Thread? Through? Operate?
  • Next by thread: Re: Thread? Through? Operate?