Skip to content

Instantly share code, notes, and snippets.

@xquery
xquery / memoization.xqy
Created May 4, 2011 05:57
Inline caching (memoization) for higher order xquery functions
xquery version "1.0-ml";
(: xquery memoization example for use with MarkLogic :)
declare variable $cache := map:map();
declare function local:factorial($n as xs:integer) as xs:integer {
if ($n < 0) then
(0)
else if ($n = 0) then