Created
February 8, 2019 09:34
-
-
Save xquery/5477c078e6d3208a2f74a74018715b17 to your computer and use it in GitHub Desktop.
example topo sort in xquery
This file contains hidden or 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:topo-sort($unsorted, $sorted ) { | |
if (empty($unsorted)) then $sorted | |
else | |
let $allnodes := $unsorted [ every $id in depends/@id satisfies $id = $sorted/@id] | |
return | |
if ($allnodes) then | |
local:topo-sort( $unsorted except $allnodes, ($sorted, $allnodes )) | |
else () | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment