MathGroup Archive 2009

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

Search the Archive

Re: second simple problem - clarification


> 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...



  • Prev by Date: Re: second simple problem
  • Next by Date: Re: simple question
  • Previous by thread: second simple problem - clarification
  • Next by thread: Problem with 3d graphics on Linux