Hi all,
I encountered a stack overflow error with the following code, which is designed to return as many random numbers as the user requests. BaseX's error suggested, "Try tail recursion?" I think I am already using tail recursion. Changing the $n variable from 1407 to 1406 or lower avoids the error. Any number 1407 or higher triggers the error.
Thank you for any hints!
Joe
```
xquery version "3.1";
declare function local:get-random-numbers($how-many as xs:integer, $generator as map(*)) {
if ($how-many ge 1) then
(
$generator?number,
local:get-random-numbers($how-many - 1, $generator?next())
)
else
()
};
declare function local:get-random-numbers($how-many as xs:integer) {
local:get-random-numbers($how-many, random-number-generator())
};
let $n := 1407
return
local:get-random-numbers($n) => count()
```