Last active
January 28, 2021 12:00
-
-
Save tirthankarkundu17/11d63fc85864c940bcc7ee0419b35ea2 to your computer and use it in GitHub Desktop.
Tail Recursion in Dataweave2
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
%dw 2.0 | |
fun tailFactorial(n:Number, prod:Number = 1) = | |
(if(n == 1 or n == 0) | |
prod | |
else | |
tailFactorial(n-1, (prod * n))) | |
output application/json | |
--- | |
tailFactorial(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment