To view the latest 11.3.x version, see PATROL Agent 11.3.02.

difference()


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

Syntax

difference(list1,list2,[list3,list4,...,listn])

Parameters

Parameter

Definition

list1

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

list2...listn

one or optionally more lists whose elements are compared against list1

Description

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.

Example

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 :
1
2
7

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*