XPath/XQuery for-each function

Summary

Returns an array whose size is the same as array:size($array), in which each member is computed by applying $function to the corresponding member of $array.

Signature

array:for-each(
$array as array(*),
$action as function(item()*) as item()*
) as array(*)

Properties

This function is deterministic, context-independent, focus-independent, and higher-order.

Rules

Returns the result of the expression: array:join( (1 to array:size($array)) ! [ $action($array(.)) ] )

Examples

The expression array:for-each(["A", "B", 1, 2], function($z) {$z instance of xs:integer}) returns [false(), false(), true(), true()].

The expression array:for-each(["the cat", "sat", "on the mat"], fn:tokenize#1) returns [("the", "cat"), "sat", ("on", "the", "mat")].