Hi Till, That's helpful. Thank you.
Yours sincerely, Riyafa On 27 July 2016 at 21:03, Till Westmann <[email protected]> wrote: > Hi Riyafa, > > the description is a spec is indeed a little terse :) > > Examples are: > > accumulate(({ "a": "b" }, { "c": "d" })) returns { "a": "b", "c": "d" } > > accumulate(({ "a": "b" }, { "a": "d" })) returns { "a": [ "b", "d" ] } > > In the second example there is a collision for the key "a" and instead of > raising an error, the function will create an array that contain all the > values for the key "a" in the source objects and use that as the value > for "a" in the result object. > > Does this make sense? > > Cheers, > Till > > > On 27 Jul 2016, at 4:46, Riyafa Abdul Hameed wrote: > > Hi, >> >> I have attempted to implement libjn:accumulate[1]. This implementation is >> based on the part of the specification[2] which states that the function >> be >> implemented as follows: >> >> declare function libjn:accumulate($sequence as item()*) as object() >> { >> {| >> for $key in $sequence() return { $key : $sequence($key) } >> |} >> }; >> >> Since this method uses the dynamic constructor for objects this will throw >> an error upon pair collision. >> But the specification also says : >> "This function dynamically builds an object, like jn:object, except that >> it >> does not throw an error upon pair collision. Instead, it accumulates them >> into an array." >> >> I am not sure I understand this because this conflicts with the previous >> (declare function) method specified and my implementation is based on the >> declare function method. What is the use of accumulating them into an >> array? Further no examples are provided on this. >> >> [1] https://github.com/apache/vxquery/pull/126 >> [2] >> >> http://jsoniq.org/docs/JSONiqExtensionToXQuery/html-single/index.html#idm139680684849856 >> >> Thank you. >> >> Yours sincerely, >> Riyafa >> -- >> Riyafa Abdul Hameed >> Undergraduate, University of Moratuwa >> >> Email: [email protected] >> Website: https://riyafa.wordpress.com/ <http://riyafa.wordpress.com/> >> <http://facebook.com/riyafa.ahf> <http://lk.linkedin.com/in/riyafa> >> <http://twitter.com/Riyafa1> >> > -- Riyafa Abdul Hameed Undergraduate, University of Moratuwa Email: [email protected] Website: https://riyafa.wordpress.com/ <http://riyafa.wordpress.com/> <http://facebook.com/riyafa.ahf> <http://lk.linkedin.com/in/riyafa> <http://twitter.com/Riyafa1>
