remove dependencies inside function?



On Oct. 2, 2012,  Stavros Macrakis wrote:
---------------------
>Per documentation, 'remove' quotes its arguments, thus *perhaps *making it 
>*
>slightly* easier to use interactively,  and definitely making it annoying
>to use programmatically.
>
>The workaround:
>
>      apply('remove, [ ydep , 'dependency ] )
--------------------------------------------------------
If I use the apply ('remove...) method, solve complains.

In the following, I first avoid any remove effort and solve
likes the task. I then replay with your remove line as part of
the function, and solve complains about something obscure.
-----------------------------------------------------------------

(%i1) display2d:false$

(%i2) dependencies;
(%o2) []

(%i3) diff11(expr,ydep,xindep) :=
block([dep,dexpr],
   dep: depends(ydep,xindep),
   dexpr : diff(expr,xindep),
   display (dexpr),
   /* apply('remove, [ ydep , 'dependency ] ),       */
   solve (dexpr, diff (ydep,xindep)))$

(%i4) diff11(y+log(y)+x,y,x);
dexpr = 'diff(y,x,1)/y+'diff(y,x,1)+1

(%o4) ['diff(y,x,1) = -y/(y+1)]

(%i5) dependencies;
(%o5) [y(x)]

(%i6) remove(y,dependency);
(%o6) done

(%i7) dependencies;
(%o7) []

(%i8) diff11(expr,ydep,xindep) :=
block([dep,dexpr],
   dep: depends(ydep,xindep),
   dexpr : diff(expr,xindep),
   display (dexpr),
   apply('remove, [ ydep , 'dependency ] ),
   solve (dexpr, diff (ydep,xindep)))$

(%i9) diff11(y+log(y)+x,y,x);
dexpr = 'diff(y,x,1)/y+'diff(y,x,1)+1

solve: all variables must not be numbers.
#0: diff11(expr=log(y)+y+x,ydep=y,xindep=x)
 -- an error. To debug this try: debugmode(true);

(%i10) dependencies;
(%o10) []

----------------------------------------
Ted