Question: Select and op command

Hi,

I have created a simple command which extracts the term containing the input. It works fine when I have more than one term in the expression but fails when there is the only one term in the expression. See below.

LT:= (expr, term)-> select(has, expr, term) #extract the operand containing the "term" in the given expression "expr"


>A:=t*u[1,1,1]*u[1,1,1,2]+2;
             

(input)>LT(A, u[1,1,1]);# works as expected, extracting the operand containing u[1,1,1]
 (output) t u[1, 1, 1] u[1, 1, 1, 2]

>op(A);#works, there are two operands
 t u[1, 1, 1] u[1, 1, 1, 2], 2

>A:=t*u[1,1,1]*u[1,1,1,2];
 

>LT(A, u[1,1,1]);#doesn't work, expected output is tu[1,1,1]u[1,1,1,2]
 u[1, 1, 1]

>op(A); doesn't work, expected output is tu[1,1,1]u[1,1,1,2]
t, u[1, 1, 1], u[1, 1, 1, 2]

Please Wait...