As you can see, this technique implements quite full and simple functional objects for Maple. It is very simple and efficient. All properties are private, you need to implement public get and set methods to make them public. Public methods and stored in the last table structure of the procedure. I'm deeply interested by comments...

> retart;

Functional object programming with Maple

Simplest functional object

> simplest_fo:=proc(n) local this, set_;
this := [n];
set_:=proc( p); this[1]:=p; end proc;
table(['get'= (x->this[1]), 'set'= set_]);
end proc;

> foo:=simplest_fo( 2);

> foo['get']();

> foo['set'](5);

> foo['get']();

Application to probability distributions

> G:=(m,s)->(t->(exp(-(t-m)^2/(2*s^2))/(sqrt(2*Pi)*s)));

> structured_distribution:=proc( f, A, B)
table(['density'= (x->f(x)), 'repartition'=(x->Int(f(t),t=A..x)), 'plot'=(t->plot(f(x),x=A..B))]);
end proc:

> SD:=structured_distribution( G(0,1), -infinity, infinity):

> SD['density'](1);

> SD['repartition'](1);

> SD['plot']();

Maple Plot




This post was generated using the MaplePrimes File Manager

View on MapleNet or Download
View file details

Please Wait...