woggy

25 Reputation

One Badge

10 years, 244 days

MaplePrimes Activity


These are questions asked by woggy

Hey guys.

Basically I want to tranverse the syntax tree, replace an indexed expression based on some rule, then return the modified expression. Here is what I am trying to do. Psuedo code below --

applyRule(expr)
   if isSymbol(expr) then
       return expr;
   elif isIndexed(expr) and ruleSatisfied then
       return modified_expr;
   else
      # Apply operator on the sub-expressions
      # This is the part im having trouble with
      return op(0,expr)(op(map(applyRule, [op(expr)])));
   end if:
end proc:

The line marked with the comment above works MOST of the time, but it'll fail for indexed objects (A[i,j] becomes A(i,j)). The unapply function looked promising, but that also has some corner cases (e.g. if I try to deconstruct the expression A = B*C it will fail)

Kind regards,

woggy

Hi guys.

I have variables that look like C[i,j,k,l], where i,j,k,l can range between 1..3 for example. Is there a simple way to create a pattern-based assumption for something like C[i,j,k,l] = C[j,i,k,l] for all i,j,k,l ?

Kind regards,

woggy

Page 1 of 1