Re: [Toybox] tsort regrets (really: hashing)

2023-11-07 Thread enh via Toybox
On Tue, Nov 7, 2023 at 11:19 AM Rob Landley wrote: > > On 11/6/23 09:39, enh wrote: > >> P.S. Yes I checked if posix/libc just had one I could use, like with > >> qsort(), > >> but man 3 hash says "This page documents interfaces provided in glibc up > >> until > >> version 2.1. Since version

Re: [Toybox] tsort regrets (really: hashing)

2023-11-06 Thread enh via Toybox
On Sun, Nov 5, 2023 at 9:50 PM Rob Landley wrote: > > On 11/5/23 21:22, Ray Gardner wrote: > > On 11/3/23 12:36:30, Rob Landley wrote: > >> > As to the hash code, the only part I've taken from Python's > >> > implementation is the probe sequence > >> > >> So... NOT the "linked lists descending

Re: [Toybox] tsort regrets

2023-11-05 Thread Rob Landley
On 11/5/23 21:24, Ray Gardner wrote: > On 11/3/23 12:36:30, Rob Landley wrote: > ... >> > One other thing: In an earlier post to the list, I pondered that I'd >> > need to do something about duplicate input pairs to tsort. Knuth's >> > approach doesn't need to be concerned about that, the

Re: [Toybox] tsort regrets (really: hashing)

2023-11-05 Thread Rob Landley
On 11/5/23 21:22, Ray Gardner wrote: > On 11/3/23 12:36:30, Rob Landley wrote: >> > As to the hash code, the only part I've taken from Python's >> > implementation is the probe sequence >> >> So... NOT the "linked lists descending from each hash bucket" approach >> then. >> >> > probe = (probe * 5

[Toybox] tsort regrets

2023-11-05 Thread Ray Gardner
On 11/3/23 12:36:30, Rob Landley wrote: ... > > One other thing: In an earlier post to the list, I pondered that I'd > > need to do something about duplicate input pairs to tsort. Knuth's > > approach doesn't need to be concerned about that, the duplicates sorta > > come out in the wash. > > //

[Toybox] tsort regrets (really: hashing)

2023-11-05 Thread Ray Gardner
On 11/3/23 12:36:30, Rob Landley wrote: > > As to the hash code, the only part I've taken from Python's > > implementation is the probe sequence > > So... NOT the "linked lists descending from each hash bucket" approach > then. > > > probe = (probe * 5 + 1 + (perturb >>= 5)) & hashmask > > where

Re: [Toybox] tsort regrets

2023-11-03 Thread Rob Landley
ut stream, it's not deal but I'm ok wasting that much space on something a given command should only have 2 or 3 of tops.) > The remark about seekable input is not for toybox; I used your tsort > code with readfd() which can handle input from terminal, pipe etc. and > grows the buffer a

[Toybox] tsort a la Knuth

2023-10-29 Thread Ray Gardner
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

[Toybox] tsort

2023-10-16 Thread Ray Gardner
In the blog, Rob said > I MOSTLY don't care because I don't know of a use case that big (he > didn't send the test data, nor say how he created it) I did say > I can post here about how I tested, if you're interested. No one said they were interested, so this will probably be my last attempt to

[Toybox] tsort

2023-10-14 Thread Ray Gardner
> The topic at hand is whether I should redo it based on a different > algorithm for better scalability up in the hundreds of thousands of > entries range. (Answer: probably yes, the numbers seem convincing. I have > to hack through a lot of math-speak from a book first published in 1968 to >

Re: [Toybox] tsort

2023-10-14 Thread Rob Landley
On 10/11/23 15:57, scsijon wrote: > I knew it from ibm mainframes and FEP's for aix, try this url for a > simple explanation, it's pretty basic what it does. > > https://www.ibm.com/docs/da/aix/7.3?topic=t-tsort-command I know what it does _now_. I wrote one from scratch that works. The topic

Re: [Toybox] tsort

2023-10-12 Thread enh via Toybox
On Thu, Oct 12, 2023 at 12:57 AM Rob Landley wrote: > > On 10/11/23 11:07, enh wrote: > >> It's not HARD, I just consider the compiler's behavior to be obviously > >> wrong > >> here. My code never performs an illegal dereference. I don't see why the > >> compiler should care what pointer values

Re: [Toybox] tsort

2023-10-12 Thread Rob Landley
On 10/11/23 11:07, enh wrote: >> It's not HARD, I just consider the compiler's behavior to be obviously wrong >> here. My code never performs an illegal dereference. I don't see why the >> compiler should care what pointer values I'm passing around when they're not >> being dereferenced: in C,

Re: [Toybox] tsort

2023-10-11 Thread enh via Toybox
On Wed, Oct 11, 2023 at 2:26 PM Ray Gardner wrote: > > On Oct 11, 2023 at 2:42 AM Rob Landley wrote: > > On 10/10/23 17:46, Ray Gardner wrote: > > > After seeing your comments about tsort in your blog, I thought about > > > trying > > > to implement Knuth's algorithm, > > > > Is that the

Re: [Toybox] tsort

2023-10-11 Thread Ray Gardner
On Oct 11, 2023 at 2:42 AM Rob Landley wrote: > On 10/10/23 17:46, Ray Gardner wrote: > > After seeing your comments about tsort in your blog, I thought about trying > > to implement Knuth's algorithm, > > Is that the recommended algorithm here? https://man.openbsd.org/tsort mentions Knuth's

[Toybox] tsort

2023-10-11 Thread scsijon
I knew it from ibm mainframes and FEP's for aix, try this url for a simple explanation, it's pretty basic what it does. https://www.ibm.com/docs/da/aix/7.3?topic=t-tsort-command scsijon ___ Toybox mailing list Toybox@lists.landley.net

Re: [Toybox] tsort

2023-10-11 Thread enh via Toybox
On Wed, Oct 11, 2023 at 1:42 AM Rob Landley wrote: > > On 10/10/23 17:46, Ray Gardner wrote: > > After seeing your comments about tsort in your blog, I thought about trying > > to > > implement Knuth's algorithm, > > Is that the recommended algorithm here? > > $ grep -i knuth

Re: [Toybox] tsort

2023-10-11 Thread Rob Landley
On 10/10/23 17:46, Ray Gardner wrote: > After seeing your comments about tsort in your blog, I thought about trying to > implement Knuth's algorithm, Is that the recommended algorithm here? $ grep -i knuth busybox/coreutils/tsort.c $ grep -ir knuth busybox

[Toybox] tsort

2023-10-10 Thread Ray Gardner
After seeing your comments about tsort in your blog, I thought about trying to implement Knuth's algorithm, but after I saw how far you'd got with your version I decided not to for now. I haven't analyzed your version carefully. It seems to be O(N^2) due to all the work to close up the list with