On Friday 09 January 2009 02:21:49 Stefano Ferri wrote:
> (%i1) freeof(I[1], I[1]);
> (%o1) false
> (%i2) freeof(I[1], I);
> (%o2) true
> (%i3) freeof(I, I[1]);
> (%o3) false
>
> %o1 and %o2 are correct, %o3 is wrong. Is it normal this behaviour?
> Maybe I've made some bad coding, in my program I've used subscript
> not only for lists and arrays, but also to distinguish the
> properties of different element of the structure, so in this
> particular case I, I[1], I[2] are separate entities. I[1] and I[2]
> don't indicate the first and the second element of I. So the above
> result %o3 from freeof is correct? But above all, why %o3 is false
> if %o2 is true?
op(I[1])=I, args(I[1])=[1]. So I[1] contains I, as an operator.
You can try something like
freeof_var (e, [x]) := block ([v : listofvars(e)],
not apply("or", map (lambda([xx], member(xx,v)), x))
)$
freeof_var (a[1] + b[2] + c[3], a,b,c) => true
freeof_var (a[1] + b[2] + c[3], a[1],b,c) => false
freeof (a,b,c, a[1] + b[2] + c[3]) => false
--
Pungenday, Chaos 8 YOLD 3175
Alexey Beshenov http://beshenov.ru/