MathGroup Archive 2005

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

Search the Archive

Re: Position function


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


  • Prev by Date: Re: how to make conditional summation
  • Next by Date: Re: Re: Simplifying ArcTan
  • Previous by thread: Re: Position function
  • Next by thread: Re: Position function