Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Creating Objects

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122311] Re: Creating Objects
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Mon, 24 Oct 2011 05:15:42 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201110231025.GAA10595@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Everything is an object already. You only need to provide behaviors.

Bobby

On Sun, 23 Oct 2011 05:25:39 -0500, Gabriel Landi <gtlandi at gmail.com>  
wrote:

> Dear MathGroup (and perhaps some Wolfram employees),
>
> Does anyone know how to create Objects in Mathematica, such as those  
> produced by LinearModelFit or NDSolve`ProcessEquations?
> For instance, let data be a set of statistical data. Then data["Mean"]  
> would give me the mean, data["Values"] would return me the original  
> values, etc.
>
> Here is an example from LinearModelFit:
>
> 	data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};
> 	lm = LinearModelFit[data, x, x];
> 	Save["Model.txt",lm];
>
> The saved output is
>
> lm = FittedModel[{"Linear", {0.18644067796610198, 0.6949152542372881},
>       {{x}, {1, x}}, {0, 0}}, {{1., 1., 1., 1.}}, {{0, 1}, {1, 0}, {3,  
> 2},
>       {5, 4}}, {{1., 0.}, {1., 1.}, {1., 3.}, {1., 5.}},
>      Function[Null, Internal`LocalizedBlock[{x}, #1], {HoldAll}]]
>
> Which has, basically, only the data and the fitted parameters.  
> Nonetheless, by doing lm["FitResiduals"] it computes the residuals for  
> me.
>
> In my impression, this is as close as one can get to object-oriented  
> programming in Mathematica, and would be a quite useful feature to use.
> I haven't found any documentation on this. Anyone knowns?
>
> Sincerely,
>
> Gabriel Landi
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: Large control loops
  • Next by Date: Re: Difficulty with patterns
  • Previous by thread: Creating Objects
  • Next by thread: Re: Creating Objects