Question: operator changing only like only in function without creating too much lines

 Function given like this

J:=0

F:=proc(operation)

J:=0;

for i to n do
    for j from i + 1 to n do if A(i, j) = 1 then J := J + mod(X (operation) Y); end if; end do; end do;
end proc;

I have simply put the word operation their to explain

If call the fuction F by F("m")  m means multiple the I should get * operator should multiple and it should multiply

If I call function F by F("A") A means Addition then should get + operator should add and it should do +

If I call function F by F("S")  S means Subtraction then should get - operator should subtract and it should do -

mod means absolute value always

Please Wait...