zook

10 Reputation

2 Badges

12 years, 245 days

MaplePrimes Activity


These are questions asked by zook

I'm trying to understand the various ways to do pattern matching. The problem is that sometimes the patterns seem to matched against a normal form that's different from the one displayed. For example can somebody explain to me why the last pattern match fails below?

> patmatch((1/2)*Zeta+(1/3)*Zeta^5, conditional(Zeta^n::posint*y::anything+z::anything, n >= 3), 's'); s;
true
[n = 5, y = 1/3, z = (1/2)*Zeta]
> patmatch(Zeta^2+(1/3)*Zeta^5, conditional...

I'm trying to use define but get unexpected behavior. Say I want to declare that the map phi is additive. I would try this

define('phi',phi(x::`+`)=map(phi,x));

But if I do phi(x+y) now, I get a warning about an infinite recursion. I get an indication of what the problem is if I define instead

define('phi',phi(x::`+`)=op(x));

Now phi(x+y) produces "x+y" rather than "x,y", so somehow the sum is considered atomic. Can somebody explain this to me?

Page 1 of 1