fn.reverse( $target as ValueIterator ) as ValueIterator
Reverses the order of items in a sequence. If $arg is the empty sequence, the empty sequence is returned.
For detailed type semantics, see Section 7.2.12 The fn:reverse function[FS].
|$target||The sequence of items to be reversed. If you pass in a single value, it is treated as a ValueIterator with that single item; therefore, if you pass in an array, the array is treated as a single value (not as one value for each item in the array). If you mean to pass in the values of each item in the array, then you can call xdmp.arrayValues on the array.|
var x = xdmp.arrayValues(["a", "b", "c"]); fn.reverse(x); => ("c", "b", "a")
fn.reverse("hello") => ("hello")
fn.reverse(null) => ()