Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2122
| From | Tomas Garza <tgarza10@msn.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: how to apply Position repeatedly without a loop? |
| Date | 2011-05-06 11:21 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iq0ljm$2lc$1@smc.vnet.net> (permalink) |
I assume you mean r instead of elements. If such be the case, then
In[1]:= A={{1,2,3},{3,4,5},{6,7,8}};r={3,6};
In[3]:= Position[A,#]&/@rOut[3]= {{{1,3},{2,1}},{{3,1}}}
-Tomas
> Date: Thu, 5 May 2011 05:24:01 -0400
> From: steve_h44@yahoo.com
> Subject: how to apply Position repeatedly without a loop?
> To: mathgroup@smc.vnet.net
>
> i have matrix A and wanted to find the Positions in this matrix of
> some elements which listed in some another vector.
>
> how to use Position to do it without a loop?
>
> I tried this:
>
> In[192]:= A={{1,2,3},
> {3,4,5},
> {6,7,8}};
> elements={3,6};
>
> Position[A,r[[1]]]
> Out[194]= {{1,1}}
>
> Position[A,r[[2]]]
> Out[197]= {{1,2}}
>
> but I want to do something like
>
> Position[A,r]
> but this does not work.
>
> I tried Map, Thread, etc.. but could not get it to work. not sure what
> the syntax is.
>
> thanks for help
> steve
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: how to apply Position repeatedly without a loop? Tomas Garza <tgarza10@msn.com> - 2011-05-06 11:21 +0000
csiph-web