Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #36218
| From | "Alex McDonald" <blog@rivadpm.com> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Reducing C, |
| Date | 2015-02-02 15:08 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <mao3sf$qfa$1@dont-email.me> (permalink) |
| References | (3 earlier) <mameqt$pal$1@speranza.aioe.org> <5pGdnRQigfSwXFPJnZ2dnUU7-XednZ2d@supernews.com> <8f3a931d-9697-411b-8e8e-4d6d8f08005a@googlegroups.com> <mannmi$8ep$1@dont-email.me> <98faaf9b-74c0-4d5a-b8f8-3c99211580af@googlegroups.com> |
on 02/02/2015 13:24:14, Mark Wills wrote: > On Monday, 2 February 2015 11:40:37 UTC, Alex McDonald wrote: >> What an awful solution. How long have you been writing Forth? > > Nice bit of drive-by trolling there, Alex. Could you not be a bit > more specific? What specifically is so awful about it? As Albert points out, please stop over-trimming your posts. The entire sense is in danger of being lost. I quote it below. > You have never posted any code on comp.lang.forth except for code > examples copied directly out of "Starting Forth" (and you get those > wrong most of th e time, because you try to do it from memory) --- the > reason why you are op posed to "more code" is because you can't write > it. > > This is a trivial coding challenge --- I was going to let the OP do it > hims elf, but since you have spoken out against the writing of Forth > code, I wil l write it myself: > > variable original-depth > >: string[ ( -- ) > depth original-depth ! ; > >: numbers-count ( -- count ) > depth original-depth @ - ; > >: reverse-numbers ( numbers... count -- numbers... ) > 0 ?do I roll loop ; > >: good-char? ( n -- flag ) > 256 u< ; > >: ]string ( numbers... -- ) > numbers-count >r > r@ reverse-numbers > r@ c, > r> 0 ?do > dup good-char? 0= abort" *** ]STRING given a bad char *** > c, loop ; > > > This is a test of the code under VFX: > > create hey ok > string[ char H char E char Y char ! ]string ok > hey count type HEY! ok > "Beauty is more important in computing than anywhere else in technology because software is so complicated. Beauty is the ultimate defence against complexity." Questions you might want to ask yourself. 1. Why are there two DO LOOPs for each string generated? 2. Why is there a ROLL on the stack for every character before it is stored? 3. Is REVERSE-NUMBERS really needed? Could it be removed? 4. Why test for "invalid" characters; but no test for a negative result in NUMBERS-COUNT; and no test for a STRING[ ]STRING in excess of 255 CHARs? 5. Why the test for a GOOD-CHAR? rather than a "bad char" as it needs 0= for the ABORT" ? No-one can teach you how to create beautiful code, but ugliness is pretty easy to spot. It's generally because the algorithm is bad in the first place, as is the case here. So this was not a drive-by troll; I assumed (wrongly in your case) that most people would look at the code with a critical eye and come to the same conclusion. Elizabeth is right, btw; unless there's a large amount of this data it's syntactic sugar. None of the offered solutions contribute much except more (ugly) code. As Albert points out, please stop over-trimming your posts. The entire sense is in danger of being lost.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Reducing C, josv@planet.nl - 2015-01-28 04:07 -0800
Re: Reducing C, Mark Wills <markwills1970@gmail.com> - 2015-01-28 05:02 -0800
Re: Reducing C, Howerd <howerdo@yahoo.co.uk> - 2015-01-28 07:42 -0800
Re: Reducing C, josv@planet.nl - 2015-01-28 08:17 -0800
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-01-29 03:37 +1100
Re: Reducing C, visualforth@rocketmail.com - 2015-01-28 12:53 -0800
Re: Reducing C, humptydumpty <ouatubi@gmail.com> - 2015-01-28 14:03 -0800
Re: Reducing C, humptydumpty <ouatubi@gmail.com> - 2015-01-28 20:39 -0800
Re: Reducing C, humptydumpty <ouatubi@gmail.com> - 2015-01-28 20:51 -0800
Re: Reducing C, josv@planet.nl - 2015-01-29 06:28 -0800
Re: Reducing C, hughaguilar96@gmail.com - 2015-01-29 21:18 -0800
Re: Reducing C, josv@planet.nl - 2015-01-30 05:38 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-01-30 15:11 +0000
Re: Reducing C, josv@planet.nl - 2015-01-30 08:34 -0800
Re: Reducing C, hughaguilar96@gmail.com - 2015-01-31 20:26 -0800
Re: Reducing C, josv@planet.nl - 2015-02-01 11:16 -0800
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-02-02 11:03 +1100
Re: Reducing C, "Elizabeth D. Rather" <erather@forth.com> - 2015-02-01 14:13 -1000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-01 17:22 -0800
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-01 17:36 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-02 11:40 +0000
Re: Reducing C, Mark Wills <markwills1970@gmail.com> - 2015-02-02 05:24 -0800
Netiquette was: Re: Reducing C, albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-02-02 13:40 +0000
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-02 15:08 +0000
Politeness, was Re: Reducing C, "Rod Pemberton" <buzz@notnotnontnooatno.cmm> - 2015-02-02 19:30 -0500
Re: Politeness, was Re: Reducing C, awegel@arcor.de (Alexander Wegel) - 2015-02-03 01:57 +0100
Re: Politeness, was Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-03 11:59 +0000
Re: Reducing C, josv@planet.nl - 2015-02-03 02:31 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-03 12:06 +0000
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-03 19:47 +0000
Re: Reducing C, josv@planet.nl - 2015-02-03 14:06 -0800
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-03 21:19 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-04 12:10 +0000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-04 18:22 -0800
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-04 19:04 -0800
Re: Reducing C, stephen@mpeforth.com (Stephen Pelc) - 2015-02-05 11:33 +0000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-05 19:39 -0800
Re: Reducing C, stephen@mpeforth.com (Stephen Pelc) - 2015-02-06 11:50 +0000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-06 11:28 -0800
Re: Reducing C, Mark Wills <markwills1970@gmail.com> - 2015-02-05 04:37 -0800
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-02-06 21:47 +1100
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-02-13 09:45 +1100
Re: Reducing C, Mark Wills <markwills1970@gmail.com> - 2015-02-13 05:24 -0800
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-02-15 13:53 +1100
Re: Reducing C, Mark Wills <markwills1970@gmail.com> - 2015-02-16 01:07 -0800
Re: Reducing C, anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-02-16 15:02 +0000
Re: Reducing C, "HAA" <someone@microsoft.com> - 2015-02-19 14:22 +1100
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-05 13:18 +0000
Re: Reducing C, josv@planet.nl - 2015-02-05 07:02 -0800
Re: Reducing C, josv@planet.nl - 2015-02-05 07:14 -0800
Re: Reducing C, josv@planet.nl - 2015-02-07 07:12 -0800
Re: Reducing C, josv@planet.nl - 2015-02-04 07:12 -0800
Re: Reducing C, november.nihal@gmail.com - 2015-02-04 09:38 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-04 21:08 +0000
Re: Reducing C, josv@planet.nl - 2015-02-05 06:45 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-06 13:21 +0000
Re: Reducing C, awegel@arcor.de (Alexander Wegel) - 2015-02-05 17:36 +0100
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-05 17:06 +0000
Re: Reducing C, awegel@arcor.de (Alexander Wegel) - 2015-02-05 18:17 +0100
Re: Reducing C, "Elizabeth D. Rather" <erather@forth.com> - 2015-02-05 10:40 -1000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-05 20:25 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-06 11:39 +0000
Re: Reducing C, awegel@arcor.de (Alexander Wegel) - 2015-02-06 12:48 +0100
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-06 17:28 -0800
Re: Reducing C, awegel@arcor.de (Alexander Wegel) - 2015-02-07 12:38 +0100
Re: Reducing C, albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-02-06 14:40 +0000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-06 18:33 -0800
Re: Reducing C, anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-02-06 13:49 +0000
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-06 14:15 +0000
Re: Reducing C, hughaguilar96@gmail.com - 2015-02-03 21:23 -0800
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-04 12:41 +0000
Re: Reducing C, "WJ" <w_a_x_man@yahoo.com> - 2015-02-04 18:19 +0000
Re: Reducing C, "WJ" <w_a_x_man@yahoo.com> - 2015-02-04 20:54 +0000
Re: Reducing C, "WJ" <w_a_x_man@yahoo.com> - 2015-02-04 09:41 +0000
Re: Reducing C, "Alex McDonald" <blog@rivadpm.com> - 2015-02-04 12:54 +0000
csiph-web