MathGroup Archive 2003

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

Search the Archive

RE: Functional programming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39035] RE: [mg39015] Functional programming
  • From: "Florian Jaccard" <jaccardf at eicn.ch>
  • Date: Sat, 25 Jan 2003 01:25:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

There are a lot of ways !

Here one way for your example :

In[18]:=MapThread[f, Transpose[({#1, 4} & )/@Range[4]]]

Out[18]={f[1, 4], f[2, 4], f[3, 4], f[4, 4]}

Or, more generally :

In[21]:=
MapThread[f, Transpose[({#1, fix} & ) /@ {a, b, c, d, e}]]

Out[21]=
{f[a, fix], f[b, fix], f[c, fix], f[d, fix], f[e, fix]}

Meilleures salutations

Florian Jaccard


-----Message d'origine-----
De : Zachary Turner [mailto:_NOzturner0826SPAM_ at hotmail.com]
Envoyé : ven., 24. janvier 2003 11:07
À : mathgroup at smc.vnet.net
Objet : [mg39015] Functional programming


I have a function f[a_,b_] defined some way.  i want to fix one argument,
and then generate an array of values where the other argument varies.  How
can I do this?

For example, I want:

{f[1, 4], f[2, 4], f[3, 4], f[4, 4]}

Is there an easy way to do this?

Thanks





  • Prev by Date: Re: Do Loop storing the outputs
  • Next by Date: Re: Do Loop storing the outputs
  • Previous by thread: RE: Functional programming
  • Next by thread: Re: Functional programming