No comment on the underlying functionality, but in terms of
programming techniques:
It is easier (and more efficient, actually) to iterate over a list
explicitly rather than with an index:
> partialdiff(fun, var):=
> block([dep,N,depexp], depexp: false,
> (for i in dependencies
> do if (part(i,0) = fun) and (part(i,1)=var) then depexp:true),
> if depexp then diff(fun,var) else 0);
and even easier and more efficient to use the built-in member function:
pd(fun, var) := if member(funmake(fun,[var]),dependencies) then
diff(fun,var) else 0$
-s