MathGroup Archive 1996

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

Search the Archive

Re: Part



Hello Hans,

> w={{1,2,3},{4,5,6},{7,8,9}}
> npos={2,1}
> 
> npos is the position of the element I need.
> 
> w[[npos]]
> 
> does not work, as it returns the second and the first
> line.


No, ...and neither should it, 
since the argument is a List of integers, not a Sequence.

You want:   
	w[[Apply[Sequence,npos]]]  

or its shorthand   
	w[[Sequence@@npos]]  
e.g.

(Zeus2.2.2) In[8]:= w[[Sequence@@npos]]
(Zeus2.2.2) Out[8]= 4


Regards,

	Ross

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ross Moore                         Internet: ross at mpce.mq.edu.au
Mathematics Department                Work:       +61 2 850-8955
Macquarie University                   Home:   please do not try
North Ryde, Sydney                     Fax:       +61 2 850-8114
Australia  2109			http://www.mpce.mq.edu.au/~ross/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  • Prev by Date: Re: Part
  • Next by Date: Re: Re: Problems with Outer
  • Previous by thread: Re: Part
  • Next by thread: Re: Part