Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #44739
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Is WHILE allowed within DO .. LOOP ? |
| Date | 2016-01-10 15:44 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Jan10.164404@mips.complang.tuwien.ac.at> (permalink) |
| References | (6 earlier) <J5qdncTosM7boxLLnZ2dnUU7-KudnZ2d@supernews.com> <2016Jan8.111957@mips.complang.tuwien.ac.at> <n6p8dq$e15$1@dont-email.me> <2016Jan9.175121@mips.complang.tuwien.ac.at> <n6rkj5$u2o$1@dont-email.me> |
Bernd Paysan <bernd.paysan@gmx.de> writes:
>Anton Ertl wrote:
>
>> The stack effect looks suspicious, but I'll ignore that for now.
>>
>> : capscomp ( c_addr1 u c_addr2 -- -1|0|1 )
>> swap bounds ?do
>> dup c@ toupper i c@ toupper - dup if
>> sgn unloop exit then
>> 1+ loop
>> drop 0 ;
>>
>> (untested) Simpler and cleaner. Not sure how slow TOUPPER is, it
>> might also be faster. It certainly saves a bit by not applying SGN to
>> 0.
>
>If you don't have sgn on 0, you could unfold it; sgn on non-0 is pretty
>easy. Tested:
>
>: capscomp ( c_addr1 u c_addr2 -- -1|0|1 )
> swap bounds ?do
> count toupper i c@ toupper - ?dup-if
> nip 0< 2* 1+ unloop exit then
> loop
> drop 0 ;
>
>Since this is for tab completion, I suppose that it's not really that
>performance critical. The -1|0|1 is probably overblow, compare returns an n
>as well.
Yes. If you want it, and since performance is not paramount, using
SGN is clearer than the optimized inlined version (as well as shorter
in the current Gforth implementation). Using C@+ is clearer than
using COUNT.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is WHILE allowed within DO .. LOOP ? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-06 16:28 +0000
Re: Is WHILE allowed within DO .. LOOP ? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-01-06 17:20 +0000
Is WHILE allowed within DO .. LOOP ? JennyB <jennybrien@googlemail.com> - 2016-01-06 09:24 -0800
Re: Is WHILE allowed within DO .. LOOP ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-01-06 16:06 -0600
Re: Is WHILE allowed within DO .. LOOP ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-07 08:36 +0000
Re: Is WHILE allowed within DO .. LOOP ? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-07 13:13 +0000
Re: Is WHILE allowed within DO .. LOOP ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-07 13:33 +0000
Re: Is WHILE allowed within DO .. LOOP ? "Elizabeth D. Rather" <erather@forth.com> - 2016-01-07 18:42 -1000
Re: Is WHILE allowed within DO .. LOOP ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-08 10:19 +0000
Re: Is WHILE allowed within DO .. LOOP ? Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-08 22:09 +0100
Re: Is WHILE allowed within DO .. LOOP ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-09 16:51 +0000
Re: Is WHILE allowed within DO .. LOOP ? Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-09 19:49 +0100
Re: Is WHILE allowed within DO .. LOOP ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-10 15:44 +0000
Re: Is WHILE allowed within DO .. LOOP ? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-01-08 11:22 +0000
Re: Is WHILE allowed within DO .. LOOP ? hughaguilar96@gmail.com - 2016-01-06 22:33 -0800
Re: Is WHILE allowed within DO .. LOOP ? Raimond Dragomir <raimond.dragomir@gmail.com> - 2016-01-06 22:47 -0800
Re: Is WHILE allowed within DO .. LOOP ? hughaguilar96@gmail.com - 2016-01-11 19:46 -0800
Re: Is WHILE allowed within DO .. LOOP ? Raimond Dragomir <raimond.dragomir@gmail.com> - 2016-01-11 22:37 -0800
csiph-web