Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #24603
| Newsgroups | comp.lang.forth |
|---|---|
| Date | 2013-07-19 09:09 -0700 |
| References | <a90e9108-640c-4d83-ad22-b21462a47668@googlegroups.com> |
| Message-ID | <ef054635-64e6-44ce-9d6c-331eccf2c51d@googlegroups.com> (permalink) |
| Subject | Re: Simple Sort - the smallest sorting routine? |
| From | Brad Eckert <hwfwguy@gmail.com> |
On Tuesday, June 25, 2013 4:12:55 PM UTC-4, The Beez wrote:
> : sort
> cells over + dup rot
> ?do
> dup i ?do i @ j @ precedes if i @ j @ i ! j ! then 1 cells +loop
> 1 cells +loop
> drop
> ;
After a bit of messing around, I hit upon the correct stack pictures. For those who aren't into solving puzzles to run code, this snippet is:
defer precedes ' < is precedes
: sort ( a n -- ) \ quick and dirty sort
cells over + dup rot
?do
dup i ?do i @ j @ precedes if i @ j @ i ! j ! then 1 cells +loop
1 cells +loop drop
;
Back to comp.lang.forth | Previous | Next | Find similar
Re: Simple Sort - the smallest sorting routine? Brad Eckert <hwfwguy@gmail.com> - 2013-07-19 09:09 -0700
csiph-web