Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: lists of variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58178] Re: lists of variables
  • From: "dkr" <dkrjeg at adelphia.net>
  • Date: Tue, 21 Jun 2005 06:02:53 -0400 (EDT)
  • References: <d9630u$q1t$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

As an addendum to my previous reply, the following example shows one
way you can use the list of variables in defining functions:

In[46]:=
var=ToExpression[Map["t"<>ToString[#]&,Range[3]]]
Out[46]=
{t1,t2,t3}

In[47]:=
f[Sequence@@Map[Function[Pattern[#,Blank[]]],var]]=Plus[Sequence@@var];

In[48]:=f[1,2,3]
Out[48]=6

Note that Set, not SetDelayed, has been used in the function
definition, since var on the righthand side must be evaluated before
pattern matching occurs.


  • Prev by Date: Re: associative arrays
  • Next by Date: Re: lists of variables
  • Previous by thread: Re: lists of variables
  • Next by thread: Re: lists of variables