Created
September 18, 2015 14:01
-
-
Save adamretter/44b345106ad6cddb92fa to your computer and use it in GitHub Desktop.
Anonymous function recursion in XQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.0"; | |
(:~ | |
: Anonymous function recursion in XQuery | |
: | |
: @author Adam Retter <[email protected]> | |
:) | |
let $factorialHelper := function($f, $x) { | |
if($x eq 0) then | |
1 | |
else | |
$x * $f($f, $x - 1) | |
} | |
let $factorial := function($x) { | |
$factorialHelper($factorialHelper, $x) | |
} | |
return | |
(: Calculate the factorial of 4 :) | |
$factorial(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment