Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!apollo!tbg From: tbg@apollo.UUCP Newsgroups: comp.lang.forth Subject: Need Forth Sort Message-ID: <3421893a.ae34@apollo.uucp> Date: Tue, 7-Apr-87 10:23:00 EST Article-I.D.: apollo.3421893a.ae34 Posted: Tue Apr 7 10:23:00 1987 Date-Received: Sat, 11-Apr-87 00:23:41 EST Organization: Apollo Computer, Chelmsford, Mass. Lines: 25 Anybody have a definition of a word that will sort 4 integers on the stack? I need one and I'm very surprised that none of the books I've got has one. Of course I could write one myself but I thought it would be a fun use of comp.lang.forth. Actually what I need is something that will check four words on the stack to see if at least three of them are approximately equal, and return the average of the approximately equal ones and a flag indicating whether there were at least 3 approximately equal values found (or garbage and a flag indicating that there were not 3 values approximately equal). Speed is important. The value used to test for "approximately equal" could be either a variable or passed as an argument, whichever is faster. I think an easy way to check for 3 approximately equal values would be to sort the 4 values first, so that's why I need a sort routine. Maybe I have the basis of a Dr. Dobb's article here, if it hasn't all been written about before. /tom