saxon:memo-function

This attribute may be set on the xsl:function element. The permitted values are yes and no. Specifying yes indicates that Saxon should remember the results of calling the function in a cache, and if the function is called again with the same arguments, the result is retrieved from the cache rather than being recalculated. Don't use this if the function has side-effects (for example, if it calls saxon:assign, or an extension function with side-effects). Don't use it if the function accesses context information such as the context node or position() or last(). And be careful if the function constructs and returns a temporary tree: the effect will be that the function returns the same tree each time, rather than a copy of the tree (this difference will only show up if you compare the identity of nodes in the two trees).

From Saxon 9.6, when XSLT 3.0 is enabled, the same effect can be achieved by setting the attributes cache="full" and identity-sensitive="no" on the xsl:function element.