[Toybox] tsort a la Knuth

Ray Gardner raygard at gmail.com
Sun Oct 29 14:34:27 PDT 2023


I wasn't going to write this, but I couldn't help myself. Had to see how
it would turn out.

This version passes the current tests/tsort.test. It also correctly prints
a loop, e.g. if the input is:

a b
b c
c a
c d
d e

it prints:

tsort: input contains a loop:
a ->
b ->
c ->
a

Note that c -> d -> e are not part of a loop.

This runs really fast even on a million lines (if run through | cat > outfile).

Ray
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tsort.c
Type: application/octet-stream
Size: 9440 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20231029/83be7a20/attachment.obj>


More information about the Toybox mailing list