Topological sort/Extracted top item: Difference between revisions

J: group dependencies by dependency level
(J: bug fix -- include files we depend on which themselves depend on nothing)
(J: group dependencies by dependency level)
Line 49:
depends=. (+. +./ .*.~)^:_ depends
keep=. +./depends (] , #~) names e. targets
>names ((<@(;:inv)/.~ /:&(keep&# ~.@]) +/"1)&(keep&#) depends
)</lang>
 
Line 58:
# 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
# When ordering names by dependencies, only consider names and dependencies we want to keep:
## only consider names and dependencies we want to keep
## group names by how many dependencies they have
## sort strings of names by how many dependencies they have
 
Example:
Line 72 ⟶ 75:
)
 
> 'top1' compileOrder dependencies
extra1 ip1a ipcommon ip2a ip2b ip2c des1b des1a1 des1a2 des1c1
extra1
des1a des1c
ip1a
ip1
ipcommon
ip2
ip2a
des1
ip2b
top1
ip2c
top1 </lang>
des1b
des1a1
des1a2
des1c1
des1a
des1c
ip1
ip2
des1
top1 </lang>
 
=={{header|Python}}==
6,962

edits