Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: [Q] How to get rid of {} ???



In article <6as8tj$f7i@smc.vnet.net>, rossiale@cisco-ags.unive.it
(Alessandro Rossi) wrote:

> Hi everyone again...
> I'm just curious to ask if is it possible to get rid of the {} simbols
> in a plain list of this kind {a1, a2, a3, ..., an} when you want to use
> the ordered sequence of a1, a2, a3, ..., an as arguments for a
> function.
> 
> e.g.
> l
> 
> 
> If I have the following list:
> list={True, False, True}
> 
> how can I computethe And Function of the three arguments of list:
> 
> And[True, False, True]
> 
> obviously 
> 
> And[list]
> 
> doesn't work...
> 
> It seems to me a very simple problem, but at the same time I really can
> not solve it. Any samaritan willing to give me some indication to solve
> this "Columbus Egg"???
> 
> TIA
> 
> Alessandro Rossi


Thd function Apply is what you are looking for.  In you example you
would write

Apply[And,list]

or use the shorthand

And@@list


Here are some examples (note the use of ## rather than # in the  pure
function of the last example):

In[1]:= And@@{x,y,z}

Out[1]= x&&y&&z

In[2]:= Apply[Plus,{x,y,z}]

Out[2]= x+y+z

In[3]:= Apply[f[##,y]&,{x,y,z}]

Out[3]= f[x,y,z,y]

-- 
David Reiss
dreissNOSPAM@nospam.earthlink.net
http://home.earthlink.net/~dreiss
To send personal email, remove the words  "nospam" and "NOSPAM" from the
email address



  • Prev by Date: 3D Graphics Spherical Coordinates
  • Next by Date: MathLink questions
  • Prev by thread: Re: 3D Graphics Spherical Coordinates
  • Next by thread: Re: [Q] How to get rid of {} ???