MarkLogic Server 11.0 Product Documentation
fn.reverse

fn.reverse(
   target as Sequence
) as Sequence

Summary

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.

Usage Notes

The sequence you specify to reverse must fit into memory, so the sequence size should not be larger than your memory cache sizes.

Example

const x = xdmp.arrayValues(["a", "b", "c"]);
fn.reverse(x);

=> ("c", "b", "a")

Example

fn.reverse("hello")

=> ("hello")

Example

fn.reverse(null)

=> ()
Powered by MarkLogic Server | Terms of Use | Privacy Policy