# map:for-each - XPath XQuery Reference

Applies a supplied function to every entry in a map, returning the concatenation of the
            results.nondeterministic-wrt-orderingcontext-independentfocus-independenthigher-orderThe function map:for-each takes any map as its $map argument and applies the supplied function
            to each entry in the map, in implementation-dependent order; the result is the sequence obtained by
            concatenating the results of these function calls.The function is non-deterministic with respect to ordering
            (see ). This means that two calls with the same arguments
            are not guaranteed to process the map entries in the same order.The function supplied as $action takes two arguments. It is called
            supplying the key of the map entry as the first argument, and the associated value as
            the second argument.map:for-each(map{1:"yes", 2:"no"}, function($k,
                  $v){$k})(1,2)This function call is equivalent to calling map:keys. The
                  result is in implementation-dependent order.distinct-values(map:for-each(map{1:"yes", 2:"no"}, function($k,
                  $v){$v}))("yes", "no")This function call returns the distinct values present in the map, in
                  implementation-dependent order.map:merge(map:for-each(map{"a":1, "b":2}, function($k,
                  $v){map:entry($k, $v+1)}))map{"a":2, "b":3}This function call returns a map with the same keys as the input map,
                  with the value of each entry increased by one.This XQuery example converts the entries in a map to attributes on a newly constructed
                  element node:
let $dimensions := map{'height': 3, 'width': 4, 'depth': 5};
return
  <box>{
     map:for-each($dimensions, function ($k, $v) { attribute {$k} {$v} })
  }</box>The result is the element <box height="3" width="4"
                  depth="5"/>.