Changes

Jump to navigation Jump to search
327 bytes added ,  23:34, 9 August 2014
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.
 
===Atomization===
If an array is ''atomized'', all of its members will be atomized. As a result, an atomized item may now result in more than one item. Some examples:
array { 1 to 2 } + 3 (: returns an error, because the left operand returns two items :)
<a>{ [ 1, 2 ]}</a> (: returns <a>1 2</a> :)
</pre>
(: Returns Atomization also applies to function arguments. The following query returns 5, because the array will be atomized to a sequence of 5 integers :) <pre class="brush:xquery">
let $f := function($x as xs:integer*) { count($x) }
return $f([1 to 5])
</pre>
 
However, the next query returns 1, because the array is already of the most general type {{Code|item()}}:
 
<pre class="brush:xquery">
let $f := function($x as item()*) { count($x) }
return $f([1 to 5])
</pre>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu