Changes

Jump to navigation Jump to search
581 bytes added ,  23:31, 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.
 
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:
 
<pre class="brush:xquery">
fn:data([1 to 2]) (: returns the sequence 1, 2 :)
[ 'a', 'b', 'c' ] = 'b' (: returns true :)
array { 1 to 2 } + 3 (: returns an error, because the left operand returns two items :)
<a>{ [ 1, 2 ]}</a> (: returns <a>1 2</a> :)
 
(: Returns 5, because the array will be atomized to a sequence of 5 integers :)
let $f := function($x as xs:integer*) { count($x) }
return $f([1 to 5])
</pre>
Arrays can be compared with the {{Code|fn:deep-equal}} function. The [[Array Module]] describes the available set of array functions.
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu