Jump to navigation Jump to search
1,163 bytes added ,  15:28, 16 December 2014
The following array functions are now available:
<code>array:size</code>, <code>array:append</code>, <code>array:subarray</code>, <code>array:remove</code>, <code>array:insert-before</code>, <code>array:head</code>, <code>array:tail</code>, <code>array:reverse</code>, <code>array:join</code>, <code>array:flatten</code>, <code>array:for-each</code>, <code>array:filter</code>, <code>array:fold-left</code>, <code>array:fold-right</code>, <code>array:for-each-pair</code>
Please check out the [[Array Module]] for more details.
fn:parse-ietf-date('28-Feb-1984 07:07:07')" (: yields 1984-02-28T07:07:07Z :),
fn:parse-ietf-date('Wed, 01 Jun 2001 23:45:54 +02:00')" (: yields 2001-06-01T23:45:54+02:00 :)
; Signatures
* <code>fn:random-number-generator() as map(xs:string, item())</code>
* <code>fn:random-number-generator($seed as xs:anyAtomicType) as map(xs:string, item())</code>
Creates a random number generator. The returned map contains three entries:
* {{Code|number}} is a random double between 0 and 1
* {{Code|next}} is a function that returns another random number generator
* {{Code|permute}} is a function that returns a random permutation of its argument
The returned random generator is ''determnistic'': If the function is called twice with the same arguments and in the same execution scope, it will always return the same result.
<pre class="brush:xquery">
let $rng := fn:random-number-generator()
let $number := $rng('number') (: returns a random number :)
let $next-rng := $rng('next')() (: returns a new generator :)
let $next-number := $next-rng('number') (: returns another random number :)
let $permutation := $rng('permute')(1 to 5) (: returns a random permutation of (1,2,3,4,5) :)
return ($number, $next-number, $permutation)
Bureaucrats, editor, reviewer, Administrators


Navigation menu