I have a sequence of length $n initialized to zeroes:
let $seq := (for $i in (1 to $n) return 0)
I can access a position easily…
return $seq[5]
…but how do I update it? (the following doesn’t work)
let $seq[5] := $seq[5] + 1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using an XQuery implementation which supports XQuery 3 maps (eg. Saxon, BaseX), you could use these:
But generally it is possible to solve a problem without maps and in most cases this code will probably run faster as it will get better optimized.