Method `^()
- Method
`^
mixed`^(mixedarg1)
mixed`^(mixedarg1,mixedarg2,mixed...extras)
mixed`^(objectarg1,mixedarg2)
mixed`^(mixedarg1,objectarg2)
int`^(intarg1,intarg2)
string`^(stringarg1,stringarg2)
array`^(arrayarg1,arrayarg2)
mapping`^(mappingarg1,mappingarg2)
multiset`^(multisetarg1,multisetarg2)
type`^(program|typearg1,program|typearg2)- Description
Exclusive or.
Every expression with the
^operator becomes a call to this function, i.e.a^bis the same aspredef::`^(a,b).- Returns
If there's a single argument, that argument is returned.
If there are more than two arguments, the result is:
`^(`^(.arg1,arg2), @extras)Otherwise, if
arg1is an object with an lfun::`^(), that function is called witharg2as argument, and its result is returned.Otherwise, if
arg2is an object with an lfun::``^(), that function is called witharg1as argument, and its result is returned.Otherwise the result depends on the argument types:
arg1can have any of the following types:intBitwise exclusive or of
arg1andarg2.stringThe result is a string where each character is the bitwise exclusive or of the characters in the same position in
arg1andarg2. The arguments must be strings of the same length.arrayThe result is an array with the elements in
arg1that doesn't occur inarg2concatenated with those inarg2that doesn't occur inarg1(according to `>, `< and `==). The order between the elements that come from the same argument is kept.Every element is only matched once against an element in the other array, so if one contains several elements that are equal to each other and are more than their counterparts in the other array, the rightmost remaining elements are kept.
mappingThe result is like
arg1but with the entries fromarg1andarg2whose indices are different between them (according to hash_value and `==).multisetThe result is like
arg1but with the entries fromarg1andarg2that are different between them (according to `>, `< and `==). Subsequences with orderwise equal entries (i.e. where `< returns false) are handled just like the array case above.type|programThe result is a type computed like this:
(.arg1&~arg2)|(~arg1&arg2)The function is not destructive on the arguments - the result is always a new instance.
- Note
If this operator is used with arrays or multisets containing objects which implement lfun::`==() but not lfun::`>() and lfun::`<(), the result will be undefined.
- See also