Created
July 29, 2022 11:33
-
-
Save adamretter/51f571d415dd6129d2490b9844c1ce00 to your computer and use it in GitHub Desktop.
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
let $permArray := function($myAr as array(*)) | |
{ | |
let $extend := function($ar as array(*), $mem as item()*) | |
{ | |
array{ | |
for $i in 1 to (array:size($ar) +1) | |
return | |
array:insert-before($ar, $i, $mem) | |
} | |
} | |
return | |
array:fold-left($myAr, [[]], | |
function($zero as array(*), $mem as item()*) | |
{ | |
array:join(for $i in 1 to array:size($zero) | |
return $extend($zero($i), $mem) ) | |
} | |
) | |
} | |
return $permArray([<a/>, 2, 3]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment