hi,
when doing a union (|) on arrays it appears as if the first array remains as is, and then any missing values from the second array are appended, with duplicates in the first array remaining.
a = ({ 1, 7, 2, 5, 4 }); b = ({ 2, 1, 3, 5, 5 });
a|b is ({ 1, 7, 2, 5, 4, 3, 5 }) b|a is ({ 2, 1, 3, 5, 5, 7, 4 })
the reason for these questions is that the tutorial claims: the elements in the result can come in any order and duplicates may or may not be removed.
should pike be (and remain) that unpredictable?
greetings, martin.
which is exactly why i am asking. i'd like to replace this attribution to voodo with a correct prediction.
greetings, martin.
good point, but claiming its random sounds wierd, something like "the current algorithm..." or not explaining it at all seems better.
greetings, martin.
The manual is inconsistent since the docs for `|() do state that order is preserved.
In my experience the documentation and the reality have never been totally in sync. Back in 7.2 the order wasn't preserved even though the docs claimed so, and later the implementation (at least 7.4+) was changed to fix that, so I don't really understand why people here say it's left undefined.
/ Jonas Walldén
Previous text:
i suppose there is a different between order that is not preserved (and thus changes frim run to run) to order that is not defined but predictably consistent.
the questions are: what result would we like to have ideally? do we get that result? if yes, then the result is not going to change and may be documented as such. if no, what is the best description for the current result that will not confuse people even if it changes later?
currently the most correct description seems to be: the order is undefined but consistently the same (for 7.6)
greetings, martin.
We like all the set operators to provide a completely well defined order on arrays, and afaik we get that in 7.4.36 and later. In 7.6 there's also a fairly detailed doc for the operators that among other thing describes the order. You're very welcome to update the tutorial with this.
/ Martin Stjernholm, Roxen IS
Previous text:
excellent, that is what i have been looking for, that document is in cvs i suppose, can you give a closer pointer?
greetings, martin.
I didn't know what document you were referring to. The tutorial is in the pike.ida.liu.se sitebuilder. The best place for a authorative description would be the reference manual, which is in the Pike CVS, refdoc/chapters.
/ Martin Nilsson (DivX Networks)
Previous text:
pike-devel@lists.lysator.liu.se