Created
July 27, 2022 12:17
-
-
Save adamretter/7d90a7e550ea7588d0684fbf45dacdd5 to your computer and use it in GitHub Desktop.
flatten-array.xqm
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
declare function local:flatten-once($ar as array(*)) as array(*) { | |
array:fold-left($ar, array{}, function($x, $y){ | |
array:join(($x, | |
if ($y instance of array(*)) | |
then | |
array { $y?* } | |
else | |
array { $y } (: for array(t) -> array(t) :) | |
)) | |
}) | |
}; | |
local:flatten-once([[[1,2], [3,4]]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment