MathGroup Archive 2004

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

Search the Archive

RE: Many Functions Into One


Bruce,

Some examples, but things also depend on how you want to merge them.

xlist = Table[1 + Random[Real, {-1, 1}], {100}];

f[list_] := {Mean[list], Variance[list]}
f[xlist]

Or

{Mean[#], Variance[#]} &[xlist]

Or

g[xlist] /. {{g -> Mean}, {g -> Variance}}

Or

MapThread[#[xlist] &, {{Mean, Variance}}]

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 




From: Bruce W. Colletti [mailto:bcolletti at compuserve.com]
To: mathgroup at smc.vnet.net

Let commands C1 and C2 have common argument X, e.g., C1 is Mean, C2 is
Variance and X is a list of reals.

Although C1@X and C2@X execute each, how can you merge these into a command
that uses X once?  I've seen this done but can't find the notes.

Thankx.

Bruce




  • Prev by Date: Re: Many Functions Into One
  • Next by Date: Re: Re: Compile
  • Previous by thread: Re: Many Functions Into One
  • Next by thread: Re: Many Functions Into One