Re: Applying position-dependent functions on lists.
- To: mathgroup at smc.vnet.net
- Subject: [mg23238] Re: Applying position-dependent functions on lists.
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 29 Apr 2000 22:04:47 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <8e0n0l$f3d@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
MapIndexed may help you because
?MapIndexed
"MapIndexed[f, expr] applies f to the elements of expr, giving the part
\
specification of each element as a second argument to f. MapIndexed[f,
expr, \
levspec] applies f to all parts of expr on levels specified by levspec."
So
MapIndexed[(pos=First[2];elem=#1; doSomethingWithPosAndElem)
&,matrix,{2}]
willgive you the positions.
Hope that helps
Jens
Manolis Petrakis wrote:
>
> Hi there
>
> I'm trying to write a program for solving the 2-D Ising model, but not using
> the standard Do[...] approach, to modify every spin on a spin list, using
> the Metropolis Function.
>
> This problem can be generalized if anyone wants to apply functions on
> matrices that depend on element positions, and require the values of nearest
> neighbor elements.
>
> If anyone understands my problem, i will be glad to receive any suggestion.
>
> -----------------------------
> Manolis Petrakis,
> University of Crete, Greece,
> Physics Dept.