Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #8023
| From | "l.i.b." <nehal.alum@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Tips for writing correct, non trivial Mathematica Libraries |
| Date | 2012-01-20 06:47 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jfb2lt$hit$1@smc.vnet.net> (permalink) |
| References | <jf8qj3$3of$1@smc.vnet.net> |
Thanks for your comments. My followups are inlined below:
> >** Take for example the following: (Taken from the mathematica 8
> >virtual book section "Applying Functions to Lists and Other
> >Expressions")
> >geom[list_] := Apply[Times, list]^(1/Length[list])
> >So, this does a bad thing for geom[ x+ y] (returns (Sqrt[x y])
>
> What were you expecting here? This looks correct to me
the snippet for 'geom' is taken for the mathematica tutorial, and is
meant to show the user how to define a function that implements the
geometric mean. so for instance,
geom[{x,y,z}] = (x y z )^(1/3). But geom[x+y] treats the expression
as a list and returns Sqrt[x y], which is not what a new user would
expect ( a better answer would be x+y)
>
> >The built-in function GeometricMean properly complains when given
> >this input,
>
I'm saying GeometricMean does not get fooled by GeometricMean[x+y],
which means the author thought of how to protect it from doing the
wrong thing -- and it would be nice to see exactly what syntax they
used.
>
> If you want to look at examples of well written Mathematica
> packages, a good place to start is to look at the packages that
> ship with Mathematica.
Actually that's exactly what I've started to do, once I nailed down
the location of the bundled packages. Though I've yet to find the
definition for GeometricMean in the install directory -- presumable it
is a native command.
Thanks
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Tips for writing correct, non trivial Mathematica Libraries Bill Rowe <readnews@sbcglobal.net> - 2012-01-19 10:17 +0000 Re: Tips for writing correct, non trivial Mathematica Libraries "l.i.b." <nehal.alum@gmail.com> - 2012-01-20 06:47 +0000
csiph-web