Re: Allowing the for member syntax to enumerate key/value pairs in a map.

On Thu, Dec 17, 2020 at 11:42 PM Reece Dunn <msclrhd@googlemail.com> wrote:

> On Fri, 18 Dec 2020 at 04:27, Dimitre Novatchev <dnovatchev@gmail.com>
> wrote:
>
>>
>>
.   .   .   .


> There is already array:flatten in XPath 3.1:
>>
>> https://www.w3.org/TR/xpath-functions-31/#func-array-flatten
>>
>
> The array:flatten function is recursive, so `array:flatten([1, [2, 3],
> 4])` will yield the sequence `(1, 2, 3, 4)`, not `(1, [2, 3], 4)`, so
> cannot be used if you just want to enumerate the members of the array! That
> is what Christian Grün is referring to, and what I meant by a
> "non-recursive array:flatten".
>
>
Then we need the  *array:flatten*  function to accept a  "*depth*"
parameter, and  *depth: 0*  will be the default and cause the current
behavior, that is unlimited depth, flatten all arrays until there are no
more arrays.

With  *depth: 1  *we will get all members of the array.

Thanks,
Dimitre

Received on Friday, 18 December 2020 15:20:12 UTC