[xquery-talk] How to Reverse an Array

Ghislain Fourny g at 28.io
Fri Jul 17 06:37:43 PDT 2015


Hi Eliot,

Forget what I said: there is actually a function for this :-)

array:reverse($array).

http://www.w3.org/TR/xpath-functions-31/#func-array-reverse

But the approach in the other query works for any other function.

Kind regards,
Ghislain

On Fri, Jul 17, 2015 at 3:31 PM, Ghislain Fourny <g at 28.io> wrote:
> Hi Eliot,
>
> I'd just go to the sequence space and back:
>
> array { reverse(array:flatten($array)) }
>
> Kind regards,
> Ghislain
>
>
> On Fri, Jul 17, 2015 at 3:26 PM, Eliot Kimber <ekimber at contrext.com> wrote:
>> I'm still getting my head around dynamic functions and arrays in XQuery
>> 3.1.
>>
>> My question for today: easiest/best/most-efficient/cleverest way to
>> reverse an array.
>>
>> You can't just use reverse() on an array, so how to produce a new array
>> that is the reverse of the input array?
>>
>> Thanks,
>>
>> Eliot
>>
>> ----
>> Eliot Kimber, Owner
>> Contrext, LLC
>> http://contrext.com
>>
>>
>>
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk


More information about the talk mailing list