Question: Maple evaluating function when it is impossible

I have a proc f(a,b)


For example

m := n->piecewise(type(n,even),0, 1):
f := proc(a,b)


when I execute f(a,b) I get 1!!


for some reason the type is returning that it is not even, even though the expansion needs to be delayed.

I did this because mod was also doing this. I replaced it so I could undefine m and actually get a general expansion in terms of m.


Is there any way to get it to delay the expansion? I guess I need to check if the type is a "variable" or not an itneger and just return it.


I've created


m := n->piecewise(type(n,even),0, type(n, integer), 1, M(n)):


which seems to work but this is not ideal because sometimes M is returned even if an integer is used when used in other expressions. I suppose it is how ever maple figures out how evaluate things.



Please Wait...