MathGroup Archive 2005

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

Search the Archive

Re: Re: Applying a list of functions to a list of arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57400] Re: Re: Applying a list of functions to a list of arguments
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 27 May 2005 04:56:38 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <d74215$ii8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

no my favorite example for the Functional 
Programming class is
#[[1]][#[[2]]] & /@ Transpose[{f, a}]

because I like the many brackets.

Regards

  Jens

"David Park" <djmp at earthlink.net> schrieb im 
Newsbeitrag news:d74215$ii8$1 at smc.vnet.net...
> Hi Jens,
>
> f = {f1, f2, f3};
> a = {a1, a2, a3};
>
> Apply @@@ Thread[{f, {#} & /@ a}]
>
> I guess that is supposed to be humorous, but I 
> hope it is never the first
> example in a Functional Programming class! It 
> depends a lot on bracket
> construction and even when I try to deconstruct 
> it, it certainly doesn't
> appear as an obvious path to the solution.
>
> {#} & /@ a
> Thread[{f, %}]
> Apply @@@ %
>
> But, darn if it doesn't work!
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> From: Jens-Peer Kuska 
To: mathgroup at smc.vnet.net
>
> Hi,
>
> Apply @@@ Thread[{f, {#} & /@ a}]
>
> ??
>
> Regards
>
>  Jens
>
> "D M Yates" <yatesd at mac.com> schrieb im
> Newsbeitrag news:d6usl9$j41$1 at smc.vnet.net...
>>I have a list of functions, and a list of
>>arguments:
>>
>> For example,
>> f = {f1, f2, f3}
>> a = {a1,a2,a3}
>>
>> I would like to return
>> {f1[a1],f2[a2],f3[a3]}
>>
>> I thought this should easy, but am stumped.
>> Obviously the lists are of
>> equal, but arbitrary length, and the arguments
>> may or may not be atomic
>> expressions. In my particular case, the
>> arguments are likely to be
>> combinations of Real, and List[Real,...], but I
>> hope this is
>> irrelevant.
>>
>> Any suggestions?
>>
>> Many thanks,
>>
>> Derek Yates
>>
>
>
>
>
> 



  • Prev by Date: Re: least-squares problem: B ~ X.A
  • Next by Date: Re: Looking for a starter documentation on package creation
  • Previous by thread: Re: Re: Applying a list of functions to a list of arguments
  • Next by thread: Re: Applying a list of functions to a list of arguments