<div dir="ltr">Correction:  fn:index-of([1,2,[3,4]], 3)</div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-26 14:30 GMT+02:00 W.S. Hager <span dir="ltr"><<a href="mailto:wshager@gmail.com" target="_blank">wshager@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Micheal,<br><br></div>Agreed, it could be implemented as a user-defined function (although this particular solution currently throws an error in eXist). However, what bothers me is that fn:index-of(1,2,[3,4], 3) may lead to unexpected results, because the array is flattened. I get the impression that array-specific semantics are sacrificed here, where in other cases they aren't, and the dividing line is still unclear me.<br><br></div>Thanks,<br></div>Wouter<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-06-26 14:16 GMT+02:00 Michael Kay <span dir="ltr"><<a href="mailto:mike@saxonica.com" target="_blank">mike@saxonica.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I would think both of these could be implemented as user-defined functions but it’s hard to know without seeing a specification: saying you want a function called array:index-of() is not very informative unless you explain exactly what you want the function to do.</div><div><br></div><div>If it’s to behave like fn:index-of() then you can write it as</div><div><br></div><div><div>array:index-of($array, $value) {</div><div>   (1 to array:size($array))[ $array(.) = $value ]</div><div>}</div></div><div><br></div><div>which is hardly a great hardship to write as a user-defined function.</div><div><br></div><div><br></div><div>Michael Kay</div><div>Saxonica</div><br><div><blockquote type="cite"><div><div><div>On 26 Jun 2015, at 12:18, W.S. Hager <<a href="mailto:wshager@gmail.com" target="_blank">wshager@gmail.com</a>> wrote:</div><br></div></div><div><div><div><div dir="ltr"><div>Hello,<br><br></div>I've been working with the recent xquery 3.1 implementation in the develop branch eXist-db. I encountered some cases that were quite hard to work around:<div><br></div><div>- the lack of array:index-of()</div><div>- the lack of the iterator index in arrayfor-each and related higher-order functions</div><div><div><div><br></div><div>Perhaps someone of the workgroup is available to discuss those cases.</div><div><br></div><div>Thanks,</div><div>Wouter<br>-- <br><div><div><p> 
W.S. Hager<br>
Lagua Web Solutions<br>
<a href="http://lagua.nl/" target="_blank">http://lagua.nl</a><br></p></div></div>
</div></div></div></div>
<br><br>-- <br><div><p> 
W.S. Hager<br>
Lagua Web Solutions<br>
<a href="http://lagua.nl/" target="_blank">http://lagua.nl</a><br></p></div><br></div></div>
_______________________________________________<br><a href="mailto:talk@x-query.com" target="_blank">talk@x-query.com</a><br><a href="http://x-query.com/mailman/listinfo/talk" target="_blank">http://x-query.com/mailman/listinfo/talk</a></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><br>-- <br><div><div>
<p> 
W.S. Hager<br>
Lagua Web Solutions<br>
<a href="http://lagua.nl/" target="_blank">http://lagua.nl</a><br></p></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div>
<p> 
W.S. Hager<br>
Lagua Web Solutions<br>
<a href="http://lagua.nl/" target="_blank">http://lagua.nl</a><br></p></div></div>
</div>