So any single-parameter function I've written which takes in a sequence
now has different behavior?
define function mysum($numbers as xs:integer*) as xs:integer
{
let $sum := 0
let $work :=
for $number in $numbers
return xdmp:set($sum, $sum + $number)
return $sum
}
mysum((1, 2, 3))
If I had the above in MarkLogic 3, I'd get back xs:integer(6). What
happens by default now in MarkLogic 4? Is mysum called three times?
Eric
Wayne Feick wrote:
Hi Florent,
This allows you to omit a FLWOR from your code. Instead of
for $x in (1, 2, 3, 4, 5)
return some-func($x)
you can just write
some-func((1, 2, 3, 4, 5))
A more concrete, real-life example would be
xdmp:document-insert(
$uri, $doc,
(xdmp:permission("owner-role", ("read", "update")),
xdmp:permission(("reader-role1", "reader-role2", "reader-role3"),
"read")))
With function mapping coming in handy for generating the permissions list.
It's just about writing more succinct code.
Also, if you declare your function to take an optional argument like
"xs:string?" then function mapping will not happen and you'll get an
exception if you pass more than one value.
Wayne.
On Thu, 2008-11-06 at 17:57 +0100, Florent Georges wrote:
Colleen Whitney wrote:
> This is the result of function mapping
I can't find out of the top of my head any use case that this new
feature is intended to solve. And of course, no use case that is worth
adding such a feature that breaks the type checking system.
Did I miss something obvious?
Regards,
------------------------------------------------------------------------
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general