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>))
 
(2 intermediate revisions by 2 users not shown)
Line 5:
These are brief notes, and do not attempt to document the language itself.
 
<langsyntaxhighlight lang=J>dependencySort=: monad define
parsed=. <@;:;._2 y
names=. {.&>parsed
Line 12:
assert.-.1 e. (<0 1)|:depends
(-.&names ~.;parsed),names /: +/"1 depends
)</langsyntaxhighlight>
 
<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.
 
<langsyntaxhighlight lang=J>depSort=: monad define
parsed=. <@;:;._2 y
names=. {.&>parsed
Line 102:
assert.-.1 e. (i.@# e.S:0"0 ])depends
(-.&names ~.;parsed),names /: #@> depends
)</langsyntaxhighlight>
 
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
Line 162:
 
I am not sure that this is the right place for such user-interface issues, but I did not find anything that looked more appropriate, and the problem about reporting new links that are not there seems to be specific to this page (it has not occured on other pages I edited).
 
: I have added a stub Forth entry to the page for you to fill in. (Thanks) --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 21:44, 22 February 2016 (UTC)
 
Thanks, I have now added the content to the entry.
6,951

edits