 
 
 
 
 
 
Re: Position function
- To: mathgroup at smc.vnet.net
- Subject: [mg55581] Re: Position function
- From: "Dan" <dantopa at gmail.com>
- Date: Wed, 30 Mar 2005 03:21:22 -0500 (EST)
- References: <d2b4q9$77c$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi konst.
Mathematica has a sweet toolkit for list operations. Try this out.
Part 1:
Map (/@) the Position operator across the array a. To do this create a
pure function from Position (#,&)
y=Position[#,1]&/@a
{{{1}, {3}, {5}}, {{3}, {4}, {6}}}
We need to remove the internal structure with the Flatten command.
Flatten/@y
{{1, 3, 5}, {3, 4, 6}}
Part 2:
x = Position[a, 1]
{{1, 1}, {1, 3}, {1,5}, {2,3}, {2,4}, {2, 6}}
The dot product is what you want. It will project out the second
components.
x.{0,1}
{1,3,5,3,4,6}
Good luck,
Dan

