I am familiar with some boolean operators. I want to access an operator that does a procedure same as below one. But for simplicity, we can say in the first step we ignore i
and j
th part of lists in order to use above operators. But for i
and j
th part we just add them to each other. I mean
IF except i
and j
according elements of two lists are different, the output has to be zero. For example in {0,1,0,0,1},{1,1,0,0,1}
the first element of the first list is 0
but the first element of the second list is 1
. The result has to be zero. but if there is not a such situation, I mean even if i
and j
be different but other elements are accordingly (one by one) equal, the result has to be in a such way that i
and j
th parts added accordingly but instead of other element must be put zero.
Assume: i=2;j=5;
Oerator[{0,1,0,0,1},{0,1,0,0,1}]={0,2,0,0,2};
Oerator[{1,1,0,0,1},{1,1,0,0,1}]={0,2,0,0,2};
Oerator[{0,1,0,0,1},{1,1,0,0,1}]=0;
Oerator[{0,1,0,0,1},{0,0,0,0,1}]={0,1,0,0,2};
Oerator[{0,1,0,0,1},{0,1,0,0,0}]={0,2,0,0,1};
Oerator[{0,1,0,1,1},{0,0,0,0,1}]=0;
Oerator[{0,1,0,1,1},{0,0,0,1,1}]={0,1,0,0,2};
0
? $\endgroup$i
/j
differ, otherwise it's the sum of the two arguments, with 0 everywhere except postionsi
andj
$\endgroup$Operator[i__][l__] := If[With[{d = {l}\[Transpose]}, And @@ Equal @@@ d[[Complement[Range@Length@d, {i}]]]], Normal[Total@{l} SparseArray@Thread[{i} -> 1]], 0]
(used asOperator[i,j][...]
) - but without a clearer explanation we can't be sure what exactly it is you want $\endgroup$