Re: Numerical Recipes Article [message #10306 is a reply to message #10273] |
Fri, 07 November 1997 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Paul E Howland wrote:
>
> Wayne Landsman wrote:
>
> As both a Mathematica and IDL user, I too was interested to read this
> article. The principal reason for the IDL code "clearly winning" lies
> in the way they have written their code. A better Mathematica example
> would have been:
>
> Reverse[#]&/@Select[Transpose[{vels,mags}], (100<#[[1]]<=200)&]
> answer=%[[Ceiling[Length[%]/4]]][[1]]
>
> which performs the sort and select without even having to explicitly
> call the Sort routine. I would argue that this is not much more
> complicated than the IDL example:
>
> temp=mags(where(vels le 200. and vels gt 100., n))
> answer=temp((sort(temp))(ceil(n/4)))
You'll have to pardon me, but I'm not a Mathematica user, and the
code here looks like it was scraped off the walls of some Egyptian
temple. If you were to show the IDL code to a programmer not familiar
with IDL, he/she could probably figure out what it's doing. Show
the Mathematica code to a programmer not familiar with Mathematica
and he'll probably think your type-writer broke.
There's often a trade-off between elegance/simplicity and
functionality. Is Mathematica's sorting capabilities that much more
flexible and powerful to justify such strange syntax?
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|