Re: second simple problem - clarification
- To: mathgroup at smc.vnet.net
- Subject: [mg99684] Re: second simple problem - clarification
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Mon, 11 May 2009 06:23:50 -0400 (EDT)
- References: <gu6675$9tv$1@smc.vnet.net>
Hi, > In the problem below, I indeed found a solution. But I wonder if there is a faster/better/more elegant one. > > My solution is: > > posiciones2=Flatten[Position[ex,"M"]]; > primerpaso=MapThread[Rule,{posiciones2,rL}]; > ReplacePart[matriz2,primerpaso] > didn't see you have a solution already. Just some minor improvements, but I think your code is alright. 1) you don't need the Flatten 2) Thread is probably clearer here than MapThread 3) no intermediate variables needed ReplacePart[ex, Thread[Position[ex, "M"] -> rL]] is doing exactly the same thing... I think it is quite clear code and shouldn't be too slow, I guess if you get faster solutions, they will be not as clear to read as this one... hth, albert