fn.reverse( target as Sequence ) as Sequence
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].
Parameters | |
---|---|
target | The sequence of items to be reversed. If you pass in a single value, it is treated as a Sequence 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. |
const x = xdmp.arrayValues(["a", "b", "c"]); fn.reverse(x); => ("c", "b", "a")
fn.reverse("hello") => ("hello")
fn.reverse(null) => ()