Talk:Topological sort: Difference between revisions
m
→J implementation: fix <lang J> tags (now <syntaxhighlight lang=J>)
m (→J implementation: fix <lang J> tags (now <syntaxhighlight lang=J>)) |
|||
Line 5:
These are brief notes, and do not attempt to document the language itself.
<
parsed=. <@;:;._2 y
names=. {.&>parsed
Line 12:
assert.-.1 e. (<0 1)|:depends
(-.&names ~.;parsed),names /: +/"1 depends
)</
<code>parsed</code> is a list of lines. Each line is a boxed list of words. Each word is a boxed list of characters.
Line 95:
Here's that alternate implementation. The algorithm remains unchanged -- I have just represented the dependencies using a different data structure.
<
parsed=. <@;:;._2 y
names=. {.&>parsed
Line 102:
assert.-.1 e. (i.@# e.S:0"0 ])depends
(-.&names ~.;parsed),names /: #@> depends
)</
In other words, instead of using a connection matrix, we use lists of name indices. In other words, the result of <code>names i.L:1 parsed</code> is
|