Re: Returning List Position w/o brackets
- To: mathgroup at smc.vnet.net
- Subject: [mg29012] Re: [mg28990] Returning List Position w/o brackets
- From: BobHanlon at aol.com
- Date: Fri, 25 May 2001 01:47:51 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
letter = {a, b, c, d, e, f, g, h};
number = {1, 2, 3, 4, 9, 2, 7, 5};
The result is a List because in general the answer is a List.
letter[[Flatten[Position[number, 2]]]]
{b, f}
If you are only interested in the first value use
letter[[Position[number, 2][[1,1]]]]
b
Bob Hanlon
In a message dated 2001/5/24 4:15:34 AM, polar at cloud9.net writes:
>Is there a way to have have the Position function return a value without
>the brackets.
>
> Say there are two lists,
> letter = {a,b,c,d} and number = {1,2,3,4}
>
> If I call letter[[2]] I get b
> but if I use letter[[ Flatten[ Position[ number, 2 ] ]
>]] I get {b}
>
> I have several large lists that I am searching through and then
>need to print out the values and I would like to have the brackets
>removed from the text reports. I hve tried several different methods
>but nothing seems to work.
>