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

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

Search the Archive

Re: Selecting Many Things Rather Than Selecting One Thi ng From Many

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66247] Re: Selecting Many Things Rather Than Selecting One Thi ng From Many
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 5 May 2006 05:02:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 5/4/06 at 5:20 AM, gregory.lypny at videotron.ca (Gregory Lypny)
wrote:

>On Wed, May 3, 2006, at 5:22 AM, Hartmut.Wolf at t-systems.com wrote:

>>In[7]:= Position[M[[All, 1]], 34 | 199 | 876]

>The OR operator is intuitive and certainly does the trick for a
>short list of things to identify.

While it maybe convenient to think of this as an Or operator and read it as such it is not. Instead it is Alternatives that is being used, i.e.,

In[4]:=
12 | 13//FullForm//TraditionalForm

Out[4]//FullForm=
Alternatives[12,13]

Contrast this with

In[5]:=
12 || 13//FullForm//TraditionalForm

Out[5]//TraditionalForm=
Or[12,13]

And setting any performance issues aside, this method can be used for lists much longer than convenient to type using Apply with a list, i.e.

Position[M[[All,1]], Alternatives@@{34,199,876}]

will produces exactly the same result. In particular,

In[9]:=
Position[Range[40],Alternatives@@Range[23,25]]

Out[9]=
{{23}, {24}, {25}}

produces the expected result but

In[10]:=
Position[Range[40],Or@@Range[23,25]]

Out[10]=
{}

which would be unexpected if you were expecting this to return the position of of 23, 24 or 25 in the data list.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Do Mathematica applications EVER get updated?
  • Next by Date: Problems with FindRoot
  • Previous by thread: Re: Re: Re: Re: )
  • Next by thread: Problems with FindRoot