Like all other values, arrays are immutable. For example, the <code>[[Array Module#array:reverse|array:reverse]]</code> function creates a new array containing a re-ordering of the members of an existing array, but the existing array is not changed by the operation. Like sequences, arrays have no identity. It is meaningful to compare the contents of two arrays, but there is no way of asking whether they are "the same array": two arrays with the same content are indistinguishable.
==Lookup Operator==
The lookup operator provides some syntactic sugar to access values of maps or array members at a specified position. It is introduced by the question mark ({{Code|?}}) and followed by a specifier. The specifier can be:
1. a wildcard: {{Code|*}},
2. the name of the key,
3. an integer offset, or
4. any other parenthesized expression.
The following example demonstrates the four alternatives:
<pre class="brush:xquery">
let $map := map { 'R': 'red', 'G': 'green', 'B': 'blue' }
return (
$map?* (: 1. returns all values :),
$map?R (: 2. returns the value associated with the key 'R'; equivalent to $map('R') :),
$map?('G','B') (: 4. returns the values associated with the key 'G' and 'B' :)
),
let $array := [ 'one', 'two', 'three' ]
return (
$array ? * (: 1. returns all values :),
$array ? 1 (: 3. returns the first value; equivalent to $array(2) :),
$array ? (2 to 3) (: 4. returns the value 2 and 3 :)
)
</pre>
The lookup operator can also be used without left operand. In this case, the context item will be used as input. This query returns {{Code|Akureyri}}:
<pre class="brush:xquery">
for $map in (
map { 'name': 'Guðrún', 'city': 'Reykjavík' },
map { 'name': 'Hildur', 'city': 'Akureyri' }
)
return $map[? name = 'Hildur'] ? city
</pre>
===Atomization===
* Arrow operator (<code>=></code>): applies a function to an item, using the item as the first argument to the function. The expression <code>$i=>$f()</code> is equivalent to <code>$f($i)</code>, and <code>$i=>$f($j)</code> is equivalent to <code>$f($i, $j)</code>.
* Lookup operator (<code>?</code>): returns the value of a map for a specific key, or the member of an array at a specified position. The expression <code>$map('name')</code> is equivalent to <code>$map?name</code>.
* Support for JSON: <code>fn:json-doc</code>, <code>fn:parse-json</code>
* New functions: <code>array:fold-left</code>, <code>array:fold-right</code>, <code>fn:collation-key</code>, <code>fn:load-module</code>, <code>fn:parse-ietf-date</code>, <code>fn:transform</code>, <code>map:for-each-entry</code>