Re: Part
- To: mathgroup at smc.vnet.net
- Subject: [mg2894] Re: [mg2890] Part
- From: "Ross Moore <ross at zeus.mpce.mq.edu.au>" <ross at zeus.mpce.mq.edu.au>
- Date: Fri, 5 Jan 1996 03:02:26 -0500
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/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==== [MESSAGE SEPARATOR] ====