Re: Undiscovered Bug?
- To: mathgroup at smc.vnet.net
- Subject: [mg46885] Re: Undiscovered Bug?
- From: lalu_bhatt at yahoo.com (Bhuvanesh)
- Date: Fri, 12 Mar 2004 23:39:44 -0500 (EST)
- References: <c2rnrf$p4h$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Harold.Noffke at wpafb.af.mil (Harold Noffke) wrote:
> MathGroup:
>
> In Mathematica 5.0.1 with Windows 2000, I mistakenly used the [[{}]]
> operator on x/y. I was expecting an error, but I kept getting unusual
> results as shown in In/Out's 2 to 5 below.
>
> Have I stumbled on a bug, or is there a way to make sense out of this?
This is the expected behavior. Quoting from the RefGuide entry for
Part:
expr[[ {i1, i2, ?} ]] gives a list of the parts i1, i2, ? of expr.
When expr is a list, expr[[ {i1, i2, ?} ]] gives a list of parts. In
general, the head of expr is applied to the list of parts.
Example:
In[1]:= expr = a[b,c];
In[2]:= expr[[{0,1,2}]]
Out[2]= a[a, b, c]
In[3]:= Apply[Head[expr], Map[Part[expr,#]&, {0,1,2}]]
Out[3]= a[a, b, c]
Cheers,
Bhuvanesh,
Wolfram Research.
--
Disclaimer: Any opinions expressed herein are my own and not
necessarily those of Wolfram Research.