This documentation space contains information about PATROL Agents when deployed in a TrueSight Operations Management environment. If you are a BMC Helix Operations Management user, see PATROL Agent 22.1 for BMC Helix Operations Management. Open link


Return the list of elements that are unique to a specified PSL list.







PSL list whose elements are being compared against the elements of all other specified lists


one or optionally more lists whose elements are compared against list1


The difference() function returns a PSL list with all elements of list1 that are not in any of the lists list2...listn. If list1 is the NULL list, the result is the NULL list. 

Duplicates are allowed in list1, and they appear in the return list in same order and number as they appeared in list1, provided that they were not removed by matches with the other lists in the difference() function. 

All elements that are returned from list1 remain in the same order in the return list. If the return list is not the NULL set, the returned set is delimited by new-line characters, that is, all set elements end with a new-line character. 

The difference() function returns a string (PSL list), hence when the return value of the function needs to be validated in the "if" condition, it should be used as described below:

  1. if(difference())!="") OR
  2. if(length(difference())) instead of if(difference())

This needs to be done since the "if" condition of the PSL interpreter treats NULL-started strings (for example, "0abc" and "0xyz"), as NULL and fails to validate these strings. Therefore NULL-started strings should be compared with some value for validation and should NOT be directly used in the "if" condition.


The following example uses the difference() function to find the elements that are unique to list1:

function main() {
list1 = [1,2,3,4,5,6,7];
list2 = [3,4,5];
list3 = [4,5,6];
unique1 = difference(list1,list2,list3);
print("Elements unique to list1 :\n",unique1);

The example produces the following output:

Elements unique to list1 :
Was this page helpful? Yes No Submitting... Thank you