MathGroup Archive 2004

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

Search the Archive

Re: Undiscovered Bug?


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.


  • Prev by Date: Re: Undiscovered Bug?
  • Next by Date: Re: Creating a symmetric matrix
  • Previous by thread: Re: Undiscovered Bug?
  • Next by thread: Re: Undiscovered Bug?