MathGroup Archive 2004

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

Search the Archive

RE: Many Functions Into One

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45516] RE: [mg45509] Many Functions Into One
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 11 Jan 2004 03:20:17 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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