Re: Position function

• To: mathgroup at smc.vnet.net
• Subject: [mg55564] Re: [mg55549] Position function
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Wed, 30 Mar 2005 03:20:58 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```a={{1,3,1,2,1},{5,6,1,1,3,1}};

Flatten[Position[#,1]]&/@a

{{1, 3, 5}, {3, 4, 6}}

Last/@Position[a,1]

{1, 3, 5, 3, 4, 6}

Bob Hanlon

>
> From: konstantpi at mail15.com
To: mathgroup at smc.vnet.net
> Date: 2005/03/29 Tue AM 03:42:32 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg55564] [mg55549] Position function
>
> suppose i have a List:
> a={{1,3,1,2,1},{5,6,1,1,3,1}}
> how i could know the positions of "1" in every sublist , i could use
Position[a
> [[1]],1] and Position[a[[2]],1]
> but i want a one formula to give me {{1,3,5},{3,4,6}}
>
> the second question:
> using Position[a,1] will give:
> {{1, 1}, {1, 3}, {1, 5}, {2, 3}, {2, 4}, {2, 6}}
> in general how to extract only the second item from every sublist so the
output
> will be;
> {1,3,5,3,4,6}
> thanks
> konst.
>
>

```

• Prev by Date: Re: Position function
• Next by Date: Re: Position function
• Previous by thread: Re: Position function
• Next by thread: Re: Position function