Overwrite builtin Functions



On 11/19/11, Rene Grothmann <renegrothmann at gmail.com> wrote:

> How can I overwrite a Maxima functions, e.g. to extend its functionality,
> something like
>
> hessian(f,[v]) := if length(v)=0 then hessian(f,listofvars(f)) else
> hessian(f,v[1])

Well, you can try this. The share package "namespaces" is an
experimental package which exposes the Lisp package machinery.
(A Lisp package is what's called a namespace in other languages.)

load (namespaces);
in_namespace (foo);
hessian(e, [v]) := if emptyp (v) then maxima|hessian (e, listofvars
(e)) else maxima|hessian (e, v);
in_namespace (maxima);
foo|hessian (x*y^2);
 => matrix([0,2*y],[2*y,2*x])

Here x|y means symbol y in namespace x.

Hope this is useful in some way.

Robert Dodier