Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #24603
| X-Received | by 10.224.172.129 with SMTP id l1mr22261119qaz.4.1374250147069; Fri, 19 Jul 2013 09:09:07 -0700 (PDT) |
|---|---|
| X-Received | by 10.49.118.232 with SMTP id kp8mr88065qeb.10.1374250147054; Fri, 19 Jul 2013 09:09:07 -0700 (PDT) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f1no41527qae.0!news-out.google.com!dk8ni705qab.0!nntp.google.com!f1no41519qae.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.forth |
| Date | Fri, 19 Jul 2013 09:09:06 -0700 (PDT) |
| In-Reply-To | <a90e9108-640c-4d83-ad22-b21462a47668@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=174.59.116.232; posting-account=6GCGIQoAAAAyO8IjR_VTwqiqLwx0Q_G8 |
| NNTP-Posting-Host | 174.59.116.232 |
| References | <a90e9108-640c-4d83-ad22-b21462a47668@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <ef054635-64e6-44ce-9d6c-331eccf2c51d@googlegroups.com> (permalink) |
| Subject | Re: Simple Sort - the smallest sorting routine? |
| From | Brad Eckert <hwfwguy@gmail.com> |
| Injection-Date | Fri, 19 Jul 2013 16:09:07 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.forth:24603 |
Show key headers only | View raw
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