From: David S. <d.s...@go...> - 2025-06-06 15:56:39
|
One problem is that many Maxima functions quote some arguments. For example, when you define this: setdepends_const(var) := (declare(var,constant), remove(var,dependency))$ "declare" and "remove" will always use the variable named "var" and not the variable that you passed to your function. You have to use "apply": apply(declare, [var, constant]) apply(remove, [var, dependency]) There are many other functions that do this. The manual should tell you. Best regards David Scherfgen Eduardo Ochs <edu...@gm...> schrieb am Fr., 6. Juni 2025, 17:40: > Hi list, > > the dependencies and the constantness of a variable seem to be stored > in two places - in "dependencies" and in properties(var). We can check > that with: > > [properties(a), diff(a)]; > declare(a,constant)$ [properties(a), diff(a)]; > remove (a,constant)$ [properties(a), diff(a)]; > [dependencies, diff(a)]; > depends(a,[x,y])$ [dependencies, diff(a)]; > remove (a,dependency)$ [dependencies, diff(a)]; > > I tried to write a function "setdepends" that would work like this, > > setdepends(a,[]) - would declare a as constant > setdepends(a,[a]) - would set a in the default way, with diff(a)=del(a) > setdepends(a,[x,y]) - would work like depends(a,[x,y]) > > I tried to write it as: > > setdepends_const(var) := (declare(var,constant), > remove(var,dependency))$ > setdepends_none (var) := (remove (var,constant), > remove(var,dependency))$ > setdepends_other(var,deps) := (remove (var,constant), depends(var,deps))$ > setdepends (var,deps) := > if equal(deps,[]) then setdepends_const(var) > elseif equal(deps,[var]) then setdepends_none (var) > else setdepends_other(var,deps)$ > > setdepends(a,[])$ diff(a); /* should yield 0 */ > setdepends(a,[a])$ diff(a); /* should yield del(a) */ > setdepends(a,[x,y])$ diff(a); /* should yield a_x del(x) + a_y del(y) > */ > > ...but my code has lots of errors, and I'm finding it hard to debug. =( > Any suggestions? > > Thanks in advance, > Eduardo Ochs > http://anggtwu.net/eev-maxima.html > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss > |