MathGroup Archive 2005

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

Search the Archive

Re : Position function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55558] Re : [mg55549] Position function
  • From: "Jaccard Florian" <Florian.Jaccard at he-arc.ch>
  • Date: Wed, 30 Mar 2005 03:20:53 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello !

You have a lot of possibilities.
For example :

In[13]:=
a = {{1, 3, 1, 2, 1}, {5, 6, 1, 1, 3, 1}}; 

First question :

In[14]:=
(Flatten[Position[#1, 1]] & ) /@ a

Out[14]=
{{1, 3, 5}, {3, 4, 6}}

Second question :

In[15]:=
Position[a, 1] /. {_, x_} -> x

Out[15]=
{1, 3, 5, 3, 4, 6}

Meilleures salutations
 
F.Jaccard


-----Message d'origine-----
De : konstantpi at mail15.com [mailto:konstantpi at mail15.com] 
Envoyé : mardi, 29. mars 2005 10:43
À : mathgroup at smc.vnet.net
Objet : [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: how to make conditional summation
  • Previous by thread: Re: Need a functional process for this.
  • Next by thread: Re: Varying colors in Plot3D according to Height