[Date Index]
[Thread Index]
[Author Index]
Re: Tips for writing correct, non trivial Mathematica Libraries
*To*: mathgroup at smc.vnet.net
*Subject*: [mg124442] Re: Tips for writing correct, non trivial Mathematica Libraries
*From*: "l.i.b." <nehal.alum at gmail.com>
*Date*: Fri, 20 Jan 2012 01:46:51 -0500 (EST)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*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
Prev by Date:
**Re: Vectorlength independet of axis-scale using VectorPlot?**
Next by Date:
**Re: Tips for writing correct, non trivial Mathematica Libraries**
Previous by thread:
**Re: Tips for writing correct, non trivial Mathematica Libraries**
Next by thread:
**Re: Tips for writing correct, non trivial Mathematica Libraries**
| |