# array:filter - XPath XQuery Reference

Returns an array containing those members of the $array for which 
            $function returns true.deterministiccontext-independentfocus-independenthigher-orderThe effect of the function is equivalent to the following recursive definition:
if (array:size($array) eq 0)
then [ ]
else op:array-concat(
        if ($function(array:head($array))) then array:head($array) else [ ],
        array:filter(array:tail($array))
     )
array:filter(["A", "B", 1, 2], function($x) {$x instance of xs:integer})[1, 2]array:filter(["the cat", "sat", "on the mat"], function($s){fn:count(fn:tokenize($s)) gt 1})["the cat", "on the mat"]array:filter(["A", "B", "", 0, 1], boolean#1)["A", "B", 1]As a consequence of the function signature and the function calling rules, a type error occurs if the supplied
            function $function returns anything other than a single xs:boolean item; there is no conversion 
            to an effective boolean value.