Skip to content

Instantly share code, notes, and snippets.

@adamretter
Created July 29, 2022 11:33
Show Gist options
  • Save adamretter/51f571d415dd6129d2490b9844c1ce00 to your computer and use it in GitHub Desktop.
Save adamretter/51f571d415dd6129d2490b9844c1ce00 to your computer and use it in GitHub Desktop.
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