Topological sort/Extracted top item: Difference between revisions

Content added Content deleted
m (fix wikilink name in j)
(J: bug fix -- include files we depend on which themselves depend on nothing)
Line 45: Line 45:
targets=. ;: x
targets=. ;: x
parsed=. <@;:;._2 y
parsed=. <@;:;._2 y
names=. ~.({.&>parsed),targets
names=. ~.({.&>parsed),targets,;parsed
depends=. (> =@i.@#) names e.S:1 parsed
depends=. (> =@i.@#) names e.S:1 (#names){.parsed
depends=. (+. +./ .*.~)^:_ depends
depends=. (+. +./ .*.~)^:_ depends
keep=. +./depends (] , #~) names e. targets
keep=. +./depends (] , #~) names e. targets
Line 56: Line 56:
# Added an argument for the target(s) we wish to find dependencies for
# Added an argument for the target(s) we wish to find dependencies for
# Make sure that these targets are included in our dependency structures
# Make sure that these targets are included in our dependency structures
# Make sure that things we can depend on are included in our dependency structures
# Select these targets, and the things they depend on, once we know what depends on what
# Select these targets, and the things they depend on, once we know what depends on what
# When ordering names by dependencies, only consider names and dependencies we want to keep
# When ordering names by dependencies, only consider names and dependencies we want to keep
Line 72: Line 73:


>'top1' compileOrder dependencies
>'top1' compileOrder dependencies
ip1
extra1
ip2
ip1a
ipcommon
des1a
ip2a
des1c
ip2b
des1
ip2c
top1 </lang>
des1b
des1a1
des1a2
des1c1
des1a
des1c
ip1
ip2
des1
top1 </lang>


=={{header|Python}}==
=={{header|Python}}==