Ewan Delanoy on Sat, 06 Oct 2012 16:48:42 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Comparing two integers in âincorrect type in comparisonâ according to GP.


Hello all,

 can anyone explain how to fix the code below. If I understood correctly, what happens that although
I know that the polcoeffâs I compute are integers on the examples I chose, the interpreter does not
and complains just because they *might* be non-integers. Should I use some kind of âconversion to intâ?

  Thanks in advance for any kind of help,

Ewan

aa_array=['a1,'a2,'a3]

decompose(expr)={
  local(positive_part,negative_part,k,pair);
  temp=vector(2,k,[k,polcoeff(expr,1,aa_array[k])]);
  positive_part=[];
  negative_part=[];
  for(k=1,3,\
   pair=temp[k];\
   if(pair[2]>0,positive_part=concat(positive_part,[pair]););\
   if(pair[2]<0,negative_part=concat(negative_part,[pair]););\
  );
  return([positive_part,negative_part])
}

example_test=decompose(a1)